Solved

Question on #define values

Posted on 2004-09-17
2
208 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
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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Title # Comments Views Activity
Interoperability issue between VC++ (ocx) & VB.NET applications 7 100
Writing a parser for java language 4 83
Best book to learn C++ 4 83
Dialogbox API leak? 18 98
When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

792 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