develooper Front page | perl.perl5.porters | Postings from June 2019

[perl #134230] Numifying a 0x string evaluates the hex number

Thread Previous
From: via RT
June 28, 2019 03:32
[perl #134230] Numifying a 0x string evaluates the hex number
Message ID:
On Thu, 27 Jun 2019 18:14:38 -0700, wrote:
> Is this a behaviour that should be changed ?

Seems to me that it's maybe a bit silly to be handing hex *integer* strings to strtod() when perl assigns hex integer barewords to IV.

It's ok when the value fits in both the IV and the NV, but when IV-precision exceeds NV-precision we can get results that don't DWIM all that well:

C:\> perl -le "print 'wtf' if 0xfffffffffffffff == '0xfffffffffffffc0' + 0;"

(That's on perl-5.30.0, ivsize and nvsize both == 8.)

It might make better sense if, in such cases, the hex integer string was handed over to srtol/strtoll.
However, strtol("023", NULL, 0) would return the decimal value 19 (same value as the perl bareword 023), but perl has always numified '023' as the decimal value 23, so there's some awkwardness there that would need to be considered.


via perlbug:  queue: perl5 status: open

Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About