8030200: Wrong result for Number.prototype.toString() for certain radix/inputs

Reviewed-by: sundar, jlaskey, lagergren
This commit is contained in:
Hannes Wallnöfer 2014-04-14 17:45:05 +02:00
parent 08bec4bee8
commit 2194adb36b
4 changed files with 43 additions and 2 deletions

View File

@ -438,7 +438,9 @@ public enum JSType {
// encode integer part from least significant digit, then reverse
do {
sb.append(chars.charAt((int) (intPart % radix)));
final double remainder = intPart % radix;
sb.append(chars.charAt((int) remainder));
intPart -= remainder;
intPart /= radix;
} while (intPart >= 1.0);

View File

@ -0,0 +1,36 @@
/*
* Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* JDK-8030200: Wrong result for Number.prototype.toString() for certain radix/inputs
*
* @test
* @run
*/
var n = 0x8000000000000800;
print(n);
var s = n.toString(5);
var m = parseInt(s, 5);
print(m === n);
print(n);

View File

@ -0,0 +1,3 @@
9223372036854778000
true
9223372036854778000

View File

@ -132,7 +132,7 @@ RangeError
2.3423446609034533e+21
2.3423446609034533e+21
11111101111101010001111111010101101000101011011001001000000000000000000
2224143002343343220233144213324
2224143002343343220233044213324
375752177255053311000000
73b92b9962990aa44400
7efa8fead15b240000