summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorTAKAI Kousuke <62541129+t-a-k@users.noreply.github.com>2021-06-22 23:54:00 +0900
committerTony Cook <tony@develop-help.com>2021-08-05 15:57:33 +1000
commit4be06921a110dfb32e3e0f8482eb8da549badb7b (patch)
treee0d22a9dfb2acc4cc4c4f778017965795b7ad628 /ext
parent972308c27284b5430c2af7fd58f80f5197a0f095 (diff)
downloadperl-4be06921a110dfb32e3e0f8482eb8da549badb7b.tar.gz
POSIX: Use NV instead of hardcoded 'double' in strtol()/strtoul().
Casting (unsigned) long value to 'double' might cause unnecessary loss of precision if double's significand is not enough wide to preserve (unsigned) long and NV is configured to be wider than double.
Diffstat (limited to 'ext')
-rw-r--r--ext/POSIX/POSIX.xs4
1 files changed, 2 insertions, 2 deletions
diff --git a/ext/POSIX/POSIX.xs b/ext/POSIX/POSIX.xs
index be45ac6fb9..2c8529bc20 100644
--- a/ext/POSIX/POSIX.xs
+++ b/ext/POSIX/POSIX.xs
@@ -3549,7 +3549,7 @@ strtol(str, base = 0)
num = strtol(str, &unparsed, base);
#if IVSIZE < LONGSIZE
if (num < IV_MIN || num > IV_MAX)
- PUSHs(sv_2mortal(newSVnv((double)num)));
+ PUSHs(sv_2mortal(newSVnv((NV)num)));
else
#endif
PUSHs(sv_2mortal(newSViv((IV)num)));
@@ -3583,7 +3583,7 @@ strtoul(str, base = 0)
num = strtoul(str, &unparsed, base);
#if UVSIZE < LONGSIZE
if (num > UV_MAX)
- PUSHs(sv_2mortal(newSVnv((double)num)));
+ PUSHs(sv_2mortal(newSVnv((NV)num)));
else
#endif
PUSHs(sv_2mortal(newSVuv((UV)num)));