in reply to Re: perl arithmetic is killing me! HELP!
in thread perl arithmetic is killing me! HELP!

Got it! Thanks. But you know, in many other programming languages, it doesn't work like that. For example, both JavaScript and Perl use 64-bit IEEE-754 double precision floats for numbers. So, doing the same complex calculation in Perl and JavaScript, one should get the SAME RESULT. That was my assumption. But that's not the reality.
  • Comment on Re^2: perl arithmetic is killing me! HELP!

Replies are listed 'Best First'.
Re^3: perl arithmetic is killing me! HELP!
by ikegami (Patriarch) on Nov 07, 2018 at 17:38 UTC

    Perl is closer to C than to JavaScript.

    $ cat a.c int main() { double x = 1; double y = 1; int z = x & y; return 0; } $ gcc -Wall -Wextra -pedantic a.c -o a && a a.c: In function ‘main’: a.c:4:15: error: invalid operands to binary & (have ‘double’ and ‘doub +le’) int z = x & y; ^ a.c:4:9: warning: unused variable ‘z’ [-Wunused-variable] int z = x & y; ^

    And the underlying reason for that is that CPUs simply can't perform bitwise-AND on floats (because it makes little sense to do so).