[vienna.pm] Seltsame String-Konversion
Peter J. Holzer
hjp-vienna-pm-list at hjp.at
Sun Feb 24 18:16:16 CST 2002
Kann mir jemand erklären, was das soll?
teal:~/tmp 0:58 109% perl -e 'print "0x030004" + 0, "\n" '
1.50003051757812
teal:~/tmp 0:59 110% perl -e 'print "0x040002" + 0, "\n"'
1.00000762939453
Laut Man-Page dürfte perl hier gar nicht konvertieren:
Octal or hex representations in string literals (e.g.
'0xffff') are not automatically converted to their integer
representation. The hex() and oct() functions make these
conversions for you. See the hex entry in the perlfunc
manpage and the oct entry in the perlfunc manpage for more
details.
und ich würde in beiden Fällen 0 erwarten. Offensichtlich führt Perl
aber doch eine korrekte Hex-Number-Konversion durch, normalisiert das
Ergebnis aber durch Shiften in das Intervall [1, 2). Wozu das?
hp
--
_ | Peter J. Holzer |
|_|_) | Sysadmin WSR | In case of emergency break laws of physics.
| | | hjp at hjp.at |
__/ | http://www.hjp.at/ | -- Stephen Baxter
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 232 bytes
Desc: not available
Url : http://mail.pm.org/archives/vienna-pm/attachments/20020225/b6b995be/attachment.bin
More information about the Vienna-pm
mailing list