Solved

Question on #define values

Posted on 2004-09-17
2
209 Views
Last Modified: 2010-04-01
I'm looking at some code, this is purely an example, but I see often things like this:

-----------------------------
#define WRITEMODE_TRACKATONCE         0x00
#define WRITEMODE_DISCATONCE          0x01
#define WRITEMODE_DISCATONCE_RAW      0x02
#define WRITEMODE_SESSIONATONCE       0x03
#define WRITEMODE_PACKET_VARIABLE     0x04
#define WRITEMODE_PACKET_FIXED        0x05

#define DISCTYPE_CDR                  0
#define DISCTYPE_CDRW                 1
#define DISCTYPE_DDCDR                2
#define DISCTYPE_DDCDRW               3
#define DISCTYPE_DVDR                 4
--------------------------------------


that's from a CD write/read library.. My question is, why are constants defined at times like 0x02  and at other times, 2 (for example) What is the fundamental difference and when choosing to go with an 0x type value, from where to do you define the values??
thanks
-paul
0
Comment
Question by:PMH4514
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 13

Accepted Solution

by:
SteH earned 50 total points
ID: 12085372
0x is hex representation. So after 0x09 comes 0x0a. It makes most sense if you want to test bit combinations which are easier to recognize in hex representation ie:
 0x0001  1
 0x0002  2
 ...
 0x0200  512
 ..
 0x1000 4096

Otherwise it is the pure choice/preference of the author of the header.
0
 

Author Comment

by:PMH4514
ID: 12085753
yeah, I realize they are hex representation.. I just wasn't sure why you'd choose one defintion over the other.  the intent to test bit combinations makes perfect sense.

thanks!
-Paul
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question