in reply to Re^3: Does anyone use Perl on Windows?
in thread Does anyone use Perl on Windows?

I have been using it all these years and have never seen a bug.

Assignment of floating point values will often be buggy in your perl.
I expect you'll (eg) be seeing:
>perl -le "$d = 1180591620717411303424.0; print unpack ('H*', reverse( +pack('d', $d)));" 444fffffffffffff
But the wrong value is being assigned to $d, and the correct result is 4450000000000000

This wasn't fixed until perl-5.30, IIRC.
I can see it going back as far as 5.10.0, but I don't go back to perl-5.8.x.
(It's not specific to Windows.)

Cheers,
Rob

Replies are listed 'Best First'.
Re^5: Does anyone use Perl on Windows?
by harangzsolt33 (Deacon) on Oct 22, 2024 at 14:20 UTC
    Indeed, 444fffffffffffff is what I got.

    Interesting!

      Interesting!

      There are many other values which are also assigned incorrectly by those old perls.
      If TinyPerl has the POSIX module you might find that assigning by using POSIX::strtod() fixes the problem.
      This works for me on my Windows perl-5.10:
      >perl -MPOSIX -le "$d = POSIX::strtod('1180591620717411303424.0'); pri +nt unpack ('H*', reverse(pack('d', $d)));" 4450000000000000
      However, IIRC, there are other values that the strtod function provided by old gcc versions (and hence also POSIX::strtod on old perls) will assign incorrectly.
      In such cases, a gcc upgrade is one solution.

      Cheers,
      Rob