EETimes

Embedded Systems September 2000 Vol13_10

Issue link: http://dc.ee.ubm-us.com/i/71837

Contents of this Issue

Navigation

Page 115 of 229

PROGRAMMING POINTERS • In C++, the only form of a floating literal Is a decimal floating literal, in which all of the digits (In both the significant part and the exponent part) are deci· mal digits. C99 also provides hexadecimal floating literals, In which the digits · of the significant part are hexadecimal digits. Appending the letter L or L to a floating literal makes its type Long double. For example, 1 . 0 F has type fLoat, and 6.022e+23L has type Long double. TABLE 1 Suffix None Decimal Literal int longint long long int U oru Lori LL or II Combining F and L (in either case and in either order) in a floating literal is a syntax error. In C++, the only form of a floating lit- eral is a decimal floating literal, in which all of the digits (in both the significant part and the exponent part) are decimal digits. C99 also provides hexadecimal floating literals, in which the digits of the significant part are hexadecimal digits. In a decimal floating literal, the Lighter areas apply only to C99 occupy at least 16 bits and a Long in t must occupy at least 32 bits. On any platform, i nt and Long i nt may occupy more than their minimum storage requirement, as long as a Long i nt occupies at least as much storage as an i nt. An tmsigned integer type must occupy the same amount of storage as its conesponding signed integer type. For instance, a 16-bit platform might use 16 bits for int and unsigned int and 32 bits for Long int and unsigned Long int. A 32-bit platform might use 32 bits for all fom types, i nt, unsigned i nt, Long i nt, and unsigned Long i nt. Table 1 describes the rules for deter- mining the type of an integer literal in C99 and C++. A literal whose value can't be represented in any of the listed types produces a compile error. The rules in Table 1 lead to some potential portability problems. A deci- mal integer literal whose value is not greater than 32,767 (= 21L1) has type i nt on every standard C and C++ envi- ronment. No swprise there. However, any decimal integer literal whose value is greater than 215-1 but not greater than 23Ll has type Long int on a 16-bit plat- form, but just plain i nt on a 32-bit plat- form. For example, given the overloaded functions: int f

Articles in this issue

Archives of this issue

view archives of EETimes - Embedded Systems September 2000 Vol13_10