in reply to Re^6: [OT: JavaScript] JS remainder operation ('%')
in thread [OT: JavaScript] JS remainder operation ('%')

Perl's weirdnesses are sometimes just inherited from it's host language C.

Choroba didn't tell us if C has the same output too, but I remember the strange rules to numify ASCII strings to integers stemming from an atoi routine in C.

use warnings; say "12x45"+1; __END__ Argument "12x45" isn't numeric in addition 13

It's not that Larry came up with all of this on his own.

FWIW I don't think this warning was always there...

Cheers Rolf
(addicted to the Perl Programming Language :)
see Wikisyntax for the Monastery

Replies are listed 'Best First'.
Re^8: [OT: JavaScript] JS remainder operation ('%')
by choroba (Cardinal) on Jan 19, 2024 at 09:50 UTC
    > Choroba didn't tell us if C has the same output too

    Well, it kind of has, but it's a bit tricky as you have to explicitly use printf.

    #include <stdio.h> int main(int argc, char** argv) { printf("%f\n", 1.4/10); printf("%.17f\n", 1.4/10); return 0; }
    Output:
    0.140000 0.13999999999999999

    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]