Reputation: 2185
I noticed that this code compiles but I have no idea why:
int main() {
double z = 0.000000000000001E-383DD;
}
But I'm not sure what the DD
at the end of the number means. I've looked through the standard but there's no mention of this.
I got this number from the following command:
$ gcc -dM -E - < /dev/null
#define __DBL_MIN_EXP__ (-1021)
#define __FLT_MIN__ 1.17549435e-38F
#define __DEC64_DEN__ 0.000000000000001E-383DD
...
Might this be a GCC extension?
Upvotes: 2
Views: 1320
Reputation: 523154
Right it's a GCC extension to indicate 64-bit decimal floating point literals.
Other extension suffixes:
Complex literals, e.g. 1.0i
, 1.0j
, 1.0fi
, etc. This purely a GCC extension and the standard C99 way is to use the macro I
(1.0*I
, 1.0f*I
, etc.)
Additional floating point types, which are purely a GCC extension:
1.0w
→ __float80
(80-bit binary floating point)1.0q
→ __float128
(128-bit binary floating point)Decimal floating point types, which is based on the proposal N1312: Extension for the programming language C to support decimal floating-point arithmetic:
1.0df
→ _Decimal32
(32-bit decimal floating point)1.0dd
→ _Decimal64
(64-bit decimal floating point)1.0dl
→ _Decimal128
(128-bit decimal floating point)Fixed-point types, which is based on the proposal N1169: Extensions to support embedded processors:
0.5hr
, 0.5r
, 0.5ulr
, etc. → _Fract
types (fixed point types with magnitude ≤ 1)5.0hk
, 5.0k
, 5.0ulk
, etc. → _Accum
types (fixed point types)Upvotes: 8
Reputation: 1638
Maybe it stands for a densely packed Decimal of 64 bits?
This wikipedia article section looks like it matches the name of the define, no?
Upvotes: 1
Reputation: 399703
Yes, it's a GCC extension to support decimal float. The literal has type _Decimal64
, but is converted when assigned to the double
variable.
Upvotes: 1