diff options
author | David Mitchell <davem@iabyn.com> | 2018-04-27 12:43:44 +0100 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2018-08-08 11:05:40 -0600 |
commit | 66f85150154f441b79024356cbc59fbafcff7c2a (patch) | |
tree | 7f4d3d550ba57d124274cc678999df984bd85ca8 /ext | |
parent | 3a778cce7686b868d662edc1334a9946c06e925d (diff) | |
download | perl-66f85150154f441b79024356cbc59fbafcff7c2a.tar.gz |
time::HiRes: don't truncate nanosec utime
When passed a floating point atime/mtime value, T::HR::utime()
was converting it into two longs: secs and nsec. But the nanosec value
was calculated using a final NV to long cast, which truncates any
fractional part rather than rounding to nearest. Use a 0.5 addition to
force rounding.
This was manifesting as a test in lib/File/Copy.t failing to preserve
the same mtime after a couple of round trips with utime() and stat().
In particular, the test was attempting to set an mtime to the literal
floating-point value
1000000000.12345
This value can't be represented exactly as an NV, so was actually
(under -Dquadmath)
1000000000.1234499999999999999999999568211720247320
which was (using truncation) being converted into the two sec/nsec
longs:
1000000000, 123449999
After this commit, it instead correctly gets converted to
1000000000, 123450000
Diffstat (limited to 'ext')
0 files changed, 0 insertions, 0 deletions