Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Question on #define values

Posted on 2004-09-17
2
Medium Priority
?
213 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 200 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

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

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. …
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
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 user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

636 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