On May 14, 2009, at 5:41 AM, Jim Bufalini wrote:

Shao Sean wrote:

Was doing some geeking with a friend in Finland and he wrote a Perl
script that got the correct answer and then we discovered that Rev is
not getting the correct answer for the multiplication.. Where is Rev
getting the extra "1" from? I have written a 64-bit binary math
library that gets the correct answer and will need to do further
testing with it to see if I get the correct answers for all the tests.


Rev: 16777619 * 2166136261 = 36342608889142560

Perl: 16777619 * 2166136261 = 36342608889142559

Is it the same thing we ran into using straight math in the scripting
competition that after 16 digits the 16th digit is rounded and you get zeros
after that? The answer is 17 digits long.

Yes. Rev appears to use IEEE double-precision binary floating point numbers. These are 64 bits: 52 for mantissa, 11 for exponent and 1 for sign. So the biggest exact integer is 2 ^ 52 - 1 which is a 16 digit number that starts with a 4. Any integer math in Rev that gives intermediate results bigger than that will not be exact. I'd give the exact number, but I don't have a calculator that will do it. I can get 2 ^ 49 and then multiply by 8 (by hand), but I promised I'd leave that alone now.

Cheer,
Jerry J

_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to