in reply to Re: Re: Why are hex numbers inside strings extrapolating to numbers (incorrectly)?
in thread Why are hex numbers inside strings extrapolating to numbers (incorrectly)?

No, I think in THIS sitation (which ISN'T taking 0x## as hex numbers) 0x10 is really the same as 0x1, 0x100, 0x183872.

Tye believes its a problem with the stdlib call atof() and I tend to agree (the same version of Perl produce different results on different OS's).


addendum: it definately is the atof() function call that is the issue.

From my Linux box with glibc 2.1.3 (that caused the strange float point results with Perl):

nicholas@neko/3:(pts-0.neko) ~/tmp > cat test.c #include <stdlib.h> int main(void) { printf("%f\n",atof("0x9")); } nicholas@neko/3:(pts-0.neko) ~/tmp > cc test.c -o test ; ./test 1.125000
and from my Solaris 2.6 box (which produced "0" with Perl):
nicholas@peacock2/5 ~ > cat >test.c #include <stdlib.h> int main(void) { printf("%f\n",atof("0x9")); } nicholas@peacock2/5 ~ > cc test.c -o test; ./test 0.000000
  • Comment on Re: Re: Re: Why are hex numbers inside strings extrapolating to numbers (incorrectly)?
  • Select or Download Code