Hi!
Can anyone explain to me why is the range of "enum e2 { a=3, b=9 };" equal to 0:15?
Hi!
Can anyone explain to me why is the range of "enum e2 { a=3, b=9 };" equal to 0:15?
Current projects:
1) User Interface Development Kit (C++)
2) HTML SDK (C++)
3) Classes (C++)
4) INI Editor (Delphi)
Range?? What do you mean by range. In your case their is no range. Could you explain the problem a litte more detailed perhaps with a sample code?
This are the examples from the Stroustrup book:
The only sence to me is e1. dark has value 0 and light has value 1. For others I have no idea.Code:enum e1 { dark, light }; // range 0:1 enum e2 { a=3, b=9 }; // range 0:15 enum e3 { min=-10, max=1000000 }; // range -1048576:1048575 enum flag {x=1, y=2, z=4, e=8 }; // range 0:15
What does that range mean anyway?
Current projects:
1) User Interface Development Kit (C++)
2) HTML SDK (C++)
3) Classes (C++)
4) INI Editor (Delphi)
I second Salem on this one.
enum e1 { dark, light }; // range 0:1
dark = 0
light = 1
0 - 1
enum e2 { a=3, b=9 }; // range 0:15
a = 3 / 0011
b = 9 / 1001^
0000 - 1111
0 - 15
enum e3 { min=-10, max=1000000 }; // range -1048576:1048575
max = 1000000 / F4240
FFFFF (16) = 1048575 (10)
enum flag {x=1, y=2, z=4, e=8 }; // range 0:15
x = 1 / 0001
y = 2 / 0010
z = 4 / 0100
e = 8 / 1000
0000 - 1111
0 - 15
MagosX.com
Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime.