Saturday, September 21, 2013

Range of enumerations according to Stroustrup

Newsgroup: comp.lang.c++

Subject: Range of enumerations according to Stroustrup

From: Peter <pilarp@...>

Date: Sat, 14 Sep 2013 11:55:06 -0700 (PDT)



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.













via Usenet Forums - Usenet Search,Free Usenet - comp.lang.c++ http://www.pocketbinaries.com/usenet-forums/showthread.php?83912-Range-of-enumerations-according-to-Stroustrup&goto=newpost

View all the progranning help forums at:

http://www.pocketbinaries.com/usenet-forums/forumdisplay.php?128-Coding-forums

No comments:

Post a Comment