in reply to Why are hex numbers inside strings extrapolating to numbers (incorrectly)?
here are the details:
i have four different machines (all linux, all i686). two of them are running perl 5.6.0, the other two 5.005.
i run the following test on all machines:
perl -e 'print("0x30"+0,"\n")'
here are the results:
first machine (5.6.0): 1.5
second machine (5.6.0): 48
third machine (5.005): 48
fourth machine (5.005): 1.5
the second and third machine always evaluate the expression to whatever the decimal value of the hex number in the string is. the first and fourh evaluate to a fractional number.
here is a test script i ran on one of the 'fractional' machines:
#!/usr/bin/perl for ($i=1; $i<64; $i++) { print(sprintf("%02X: ",$i),("0x".sprintf("%X",$i))+0,"\n"); }
here is the output:
01: 1 02: 1 03: 1.5 04: 1 05: 1.25 06: 1.5 07: 1.75 08: 1 09: 1.125 0A: 1.25 0B: 1.375 0C: 1.5 0D: 1.625 0E: 1.75 0F: 1.875 10: 1 11: 1.0625 12: 1.125 13: 1.1875 14: 1.25 15: 1.3125 16: 1.375 17: 1.4375 18: 1.5 19: 1.5625 1A: 1.625 1B: 1.6875 1C: 1.75 1D: 1.8125 1E: 1.875 1F: 1.9375 20: 1 21: 1.03125 22: 1.0625 23: 1.09375 24: 1.125 25: 1.15625 26: 1.1875 27: 1.21875 28: 1.25 29: 1.28125 2A: 1.3125 2B: 1.34375 2C: 1.375 2D: 1.40625 2E: 1.4375 2F: 1.46875 30: 1.5 31: 1.53125 32: 1.5625 33: 1.59375 34: 1.625 35: 1.65625 36: 1.6875 37: 1.71875 38: 1.75 39: 1.78125 3A: 1.8125 3B: 1.84375 3C: 1.875 3D: 1.90625 3E: 1.9375 3F: 1.96875
now what i need is an explanation :)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Why are hex numbers inside strings extrapolating to numbers (incorrectly)?
by MrNobo1024 (Hermit) on Feb 26, 2001 at 20:46 UTC |