Scott Frazer
Scott Frazer

Reputation: 2185

C floating point number notation

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

Answers (3)

kennytm
kennytm

Reputation: 523154

Right it's a GCC extension to indicate 64-bit decimal floating point literals.

Other extension suffixes:

Upvotes: 8

Nick Beeuwsaert
Nick Beeuwsaert

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

unwind
unwind

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

Related Questions