in reply to -Duse64bitint and (Cygwin) perl 5.8.7
It can get tricky when you have the situation where your "int"s can hold more significant bits than your "double"s, but, of course, your doubles can deal with larger and smaller exponents than your ints. So, when you have two Perl numeric values to do an operation with, should you perform the operation as ints or as doubles?
Before 64-bit ints, the decision was simple; you do all math as doubles because the doubles can do everything the ints can do.
To counter your example, consider:
$x = 2 ** 45 + 1; $y = 2 ** 45 + 1.5; if($x + .5 == $y) {print "fine\n"} else {print "crap\n"} if($x == $y) {print "crap\n"} else {print "fine\n"} # Then $x = 1e55 + 1e44; $y = 1e55 + 2e44; # ...
Is Perl smart enough to tell that it needs to do your example with 64-bit ints but that it needs to do my examples with doubles? Obviously not. Can it be made that smart? Perhaps, but it might not be easy.
You could perlbug this to give the maintainers something to think about. But I hope you have a better appreciation for the difficultly here.
Note that you can help Perl know what you want here with a simple use integer;.
- tye
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: -Duse64bitint and (Cygwin) perl 5.8.7 (it's not how many bits, but how you use them)
by syphilis (Archbishop) on Nov 30, 2006 at 08:38 UTC | |
|
Re^2: -Duse64bitint and (Cygwin) perl 5.8.7 (it's not how many bits, but how you use them)
by mersenne (Initiate) on Nov 30, 2006 at 16:37 UTC |