summaryrefslogtreecommitdiff
path: root/pod/perldata.pod
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2014-08-12 08:39:40 -0400
committerJarkko Hietaniemi <jhi@iki.fi>2014-08-13 22:44:06 -0400
commit61e61fbc49c95894c46dd5128133731fc2092e07 (patch)
tree000efc7c83f1e235f440163bca5f467b3299558b /pod/perldata.pod
parent40bca5ae9c72f416f0e0e056ecf8e205a03e5be3 (diff)
downloadperl-61e61fbc49c95894c46dd5128133731fc2092e07.tar.gz
Hexadecimal float literals, for perl #122219
Do not use system strtod/strtold since its C99 (which we do not require). If we can fit the mantissa bits of a NV to a UV (which is the case for the most common format, 64-bit IEEE 754 double, which has 52 mantissa bits) we will use that, and only in the end convert to NV. If we cannot fit the bits, accumulate the bits incrementally to a NV.
Diffstat (limited to 'pod/perldata.pod')
-rw-r--r--pod/perldata.pod9
1 files changed, 9 insertions, 0 deletions
diff --git a/pod/perldata.pod b/pod/perldata.pod
index d8edfe94f1..fe39783dd3 100644
--- a/pod/perldata.pod
+++ b/pod/perldata.pod
@@ -402,6 +402,7 @@ integer formats:
0xdead_beef # more hex
0377 # octal (only numbers, begins with 0)
0b011011 # binary
+ 0x1.999ap-4 # hexadecimal floating point (the 'p' is required)
You are allowed to use underscores (underbars) in numeric literals
between digits for legibility (but not multiple underscores in a row:
@@ -425,6 +426,14 @@ Hexadecimal, octal, or binary, representations in string literals
representation. The hex() and oct() functions make these conversions
for you. See L<perlfunc/hex> and L<perlfunc/oct> for more details.
+Hexadecimal floating point can start just like a hexadecimal literal,
+and it can be followed by an optional fractional hexadecimal part,
+but it must be followed by C<p>, an optional sign, and a power of two.
+The format is useful for accurately presenting floating point values,
+avoiding conversions to or from decimal floating point, and therefore
+avoiding possible loss in precision. Notice that while most current
+platforms use the 64-bit IEEE 754 floating point, not all do.
+
You can also embed newlines directly in your strings, i.e., they can end
on a different line than they begin. This is nice, but if you forget
your trailing quote, the error will not be reported until Perl finds