# enumeration

• 04-03-2003
GaPe
enumeration
Hi!

Can anyone explain to me why is the range of "enum e2 { a=3, b=9 };" equal to 0:15?
• 04-03-2003
ripper079
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?
• 04-03-2003
GaPe
This are the examples from the Stroustrup book:

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```
The only sence to me is e1. dark has value 0 and light has value 1. For others I have no idea.
What does that range mean anyway?
• 04-03-2003
Magos
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