|Problems? Is your data what you think it is?
weird problem with macports perl on apple m1/m2 based systemby perltux (Monk)
|on Jun 10, 2023 at 19:19 UTC
perltux has asked for the wisdom of the Perl Monks concerning the following question:
I have written a fairly complex Perl-Tk application that runs fine on Linux, FreeBSD and on Intel Macs (using MacPorts Perl-Tk).
But on Macs based on M1/M2 cpu (again using MacPorts Perl-Tk) simple floating point arithmetics fail to return the correct result, instead the floating point parts of the operands are ignored and the result is calculated like if it was integer numbers.
For example on Linux and Intel Mac 12.99 * 16.25 returns 211.0875, which is correct, but on M1/M2 Macs with MacPorts Perl I get 192, so Perl is simply doing 12 * 16, completely ignoring the decimals.
I have written a small Perl-Tk script that reproduces this problem (this is really an extract from my application that's why it might look unnecessarily convoluted):
This test program can also be downloaded from my website at the following URL: http://obd-amigos.linuxtech.net/test1/amigos-test1.pl
Is there anybody here who uses MacPorts Perl on a M1/M2 Mac who can reproduce this issue with the above test script and perhaps has an idea why this happens?
I'm thinking of opening a bug report at MacPorts but would prefer to first get some feedback here in case it's not a MacPorts issue.
Thanks in advance for any testing / feedback / opinions / insights.
Edit: changed "use POSIX;" to "use POSIX qw(strftime);" in the test script.