#725449 perl-doc: underspecified semantics of numbers and numeric operations

#725449#5
Date:
2013-10-05 23:48:55 UTC
From:
To:
[Reported in perl-doc, but there could also be bugs in perl itself.]

The semantics of numbers and numeric operations seems to be specified
in the perlnumber(1) man page, but various operations are not specified
at all and seem to be inconsistent, maybe buggy. For instance,

$ perl -e 'printf "%f\n", 0./0.'
Illegal division by zero at -e line 1.

$ perl -e 'printf "%f\n", 1./0.'
Illegal division by zero at -e line 1.

Why an error and not NaN (resp. Inf), as per IEEE 754 rules?

Note that Perl seems to have Inf and NaN support, hence the above
question:

$ perl -e 'printf "%f\n", exp(1000)'
inf

$ perl -e 'printf "%f\n", exp(1000)-exp(1000)'
-nan

Why does one get the following?

$ perl -e 'printf "%f\n", "0x12"'
0.000000

0x12, if not interpreted as a hex number, should probably regarded as
an invalid numeric value, thus it should give NaN or an error (like
the operation 0./0.).

FYI:

$ /usr/bin/printf "%f\n" 0x12
18.000000