P
Peter
In Stroustrup's book the following statement can be found:
"The range of an enumeration holds all the enumeration's enumerator values rounded up to the nearest larger binary power minus 1. The range goes down to 0 if the smallest enumerator is non-negative and to the nearest lesser negative binary power if the smallest enumerator is negative".
The statement is followed by an example which contradicts the rule stated above:
enum e3 { min = -10, max = 1000000 }; // range -1048576:1048575
Why would the lower limit be -1048576? The smallest enumerator is -10 and the nearest negative binary power lesser than -10 is -16, not -1048576.
"The range of an enumeration holds all the enumeration's enumerator values rounded up to the nearest larger binary power minus 1. The range goes down to 0 if the smallest enumerator is non-negative and to the nearest lesser negative binary power if the smallest enumerator is negative".
The statement is followed by an example which contradicts the rule stated above:
enum e3 { min = -10, max = 1000000 }; // range -1048576:1048575
Why would the lower limit be -1048576? The smallest enumerator is -10 and the nearest negative binary power lesser than -10 is -16, not -1048576.