In article <fm*********@ulysses.noc.ntua.gr>,
jo**@no.spam says...
[ ... ]
float f= 0f; // doesn't seem to work
Correct -- here's the syntax from the standard ($2.13.3):
floating-literal:
fractional-constant exponent-part[opt]
floating-suffix[opt]
digit-sequence exponent-part floating-suffix[opt]
fractional-constant:
digit-sequence[opt] . digit-sequence
digit-sequence .
[ ... ]
floating-suffix: one of
f l F L
So the "fractional-constant" must have a decimal point and at least one
digit either before or after the decimal point.
float f= 0.f // Is this valid?
float f= 0.F // Is this valid?
Yes to both.
float f= 0.0f; // It works
float f= 0.0F // Does 'F' mean float here?
Yes, in both cases.
float f= 0.0 // is 0.0 a double here?
Yes.
double d= 0.0d // doesn't seem to work. Is there any double
// specification like 'f' for float?
No, as you can see above, the only suffixes are F and L, in either upper
or lower case.
long double d= 0.0l // Does 'l' mean long double here?
long double d= 0.0L // Does 'L' mean long double here?
Yes, it does.
// L is also used for wchar_t character constants
// and string literals.
It's used as a prefix for string and character constants.
long i= 1L; // Does 'L' mean long?
long i= 1l; // Does 'l' mean long?
Yes to both. A suffix of "LL" denotes a long long in C99, and will
undoubtedly mean the same in C++ 0x. For integers, you can also use a
suffix of 'u' or 'U' to indicate an unsigned; this can be combined with
'l' or 'L' to indicate an unsigned long. These are all case insensitive,
so you can mix and match as you see fit, so the following are all
equivalent:
1uL
1UL
1ul
1Ul
Most people recommend that you only use the upper-case 'L' for this
purpose, as the lower-case version can be difficult to distinguish from
the digit one in many fonts.
--
Later,
Jerry.
The universe is a figment of its own imagination.