Skip to content

Commit 667298d

Browse files
authored
Merge pull request certik#39 from pdebuyl/master
ENH: omitting a dot demotes a literal to an integer
2 parents 34e555f + d1b9a92 commit 667298d

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/best-practices.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ Always write all floating point constants with the ``_dp`` suffix::
8383

8484
and never any other way (see also the gotcha
8585
:ref:`floating_point_numbers_gotcha`).
86+
Omitting the dot in the literal constant is also incorrect.
8687

8788
To print floating point double precision
8889
numbers without losing precision, use the ``(es23.16)`` format (see

src/gotchas.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,13 @@ And so it is safe to assign integers to floating point numbers without losing
6161
any accuracy (but one must be careful about integer division, e.g. ``1/2`` is
6262
equal to ``0`` and not ``0.5``).
6363

64+
The declaration of integer variables with a ``_dp`` suffix does not promote them
65+
automatically to double precision variables. The following literal::
66+
67+
360_dp
68+
69+
is interpreted as an integer.
70+
6471
C/Fortran Interoperability of Logical
6572
-------------------------------------
6673

0 commit comments

Comments
 (0)