Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is the "d" in "double x = 0.0d;" a g++ extension?

Tags:

c++

g++

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.

like image 947
Ken Y-N Avatar asked Nov 05 '19 08:11

Ken Y-N


1 Answers

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.

like image 173
n. 1.8e9-where's-my-share m. Avatar answered Nov 01 '22 07:11

n. 1.8e9-where's-my-share m.