I have come across some code that basically is:
double x = 0.0d;
The d suggests to me that this is a suffix for doubles, but the documentation for floating point literals does not have it, and I cannot find any mention in the GNU g++ documentation. The compiler doesn't throw out any warnings either with -Wall.
I've made a small sample on GodBolt which answers my question with -Wpedantic, but I'd still like to see the documentation for this issue.
* Note that a similar question for Java exists.
This is specified in ISO/IEC TR 24732 a.k.a. WG14 N1312 technical report "Extension for the programming language C to support decimal floating-point arithmetic".
It defines d as a suffix for plain double type, and several other suffixes for decimal floating point types.
See it here (PDF).
gcc documentation mentions all these other suffixes, but not d. It is an omission.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With