Status: New
Owner: ----
New issue 1525 by [email protected]: v8 can't convert number to string
correctly even if the number is a 43bit precision integer.
http://code.google.com/p/v8/issues/detail?id=1525
v8 can't print the integer correctly.
for example:
(in Ubuntu 11.04 64bit, but built in 32bit)
----
$d8
V8 version 3.4.8 [console: readline]
d8> print(76287755398823936);
76287755398823940
----
I thought this happened because of the limit of double(53bit precision),
but this number, 76287755398823936, can be represented correctly in double,
because this number have only 43 digit.
76287755398823936
= 0b100001111000001110100111100110001010000100100000000000000
So, other languages can print this number correctly.
for example:
---
$cat test.c
#include <stdio.h>
#include <stdlib.h>
int main(int argc,char** argv){
long long num = 76287755398823936LLU;
double num_double = (double) num;
long long num2 = (long long)num_double;
printf("long long %llu\n", num);
printf("double: %f\n", num_double);
printf("long long2: %llu\n", num2);
}
$gcc limit.c
$./a.out
long long 76287755398823936
double: 76287755398823936.000000
long long2: 76287755398823936
---
Then, here is a cause of this problem.
http://www.google.com/codesearch#W9JxUuHYyMg/trunk/src/fast-dtoa.cc&q=FastDtoa.%20package:http://v8\.googlecode\.com&l=608
Computed boundaries are:
boundary_minus: 76287755398823928
boundary_plus: 76287755398823944
(w: 76287755398823936)
This differences between boundaries and w appear as the wrong value in the
converted string.
This problem occurs only when converting double to string, and internal
double value keeps the correct value, so calculating between this number
and other is not affected by this.
---
$ ./d8
V8 version 3.4.8 [console: readline]
d8> print(76287755398823936/1024)
74499761131664 <- correct answer.
d8>
---
Is this a bug?
Other computer languages can print correctly, so I think v8 also should be
able to print this number correctly...
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev