Comment #2 on issue 3025 by [email protected]: number.toString(5)
doesn't generate the correct result.
http://code.google.com/p/v8/issues/detail?id=3025
Works fine on ia32.release :-)
The behavior you describe happens on ia32.debug as well as
x64.{release,debug}.
This may be WAI. You're asking the poor toString() function to compute
accurate digits that simply aren't there in the double representation of
the input number. The 80bit FPU apparently manages to hide this.
It's true that 0x8000000000000800 can be stored as a double without losing
any of the 1-bits -- but you're still losing information about bits that
happened to be 0:
$ out/ia32.release/d8 -e "print(0x8000000000000800 == 0x8000000000000bff)"
true
I did notice that our implementation looks a little fishy, and for your
example we can get two more correct digits with the following patch:
diff --git a/src/conversions.cc b/src/conversions.cc
index 5f1219e..3705563 100644
--- a/src/conversions.cc
+++ b/src/conversions.cc
@@ -401,8 +401,10 @@ char* DoubleToRadixCString(double value, int radix) {
// at least one digit.
int integer_pos = kBufferSize - 2;
do {
+ double remainder = fmod(integer_part, radix);
integer_buffer[integer_pos--] =
- chars[static_cast<int>(fmod(integer_part, radix))];
+ chars[static_cast<int>(remainder)];
+ integer_part -= remainder;
integer_part /= radix;
} while (integer_part >= 1.0);
// Sanity check.
But that doesn't change the fundamental fact that you can't expect integer
precision from JS numbers larger than 2^52.
--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.