mirror of
https://github.com/corda/corda.git
synced 2025-01-22 12:28:11 +00:00
fix Long.toString for Long.MIN_VALUE case
This commit is contained in:
parent
bf58eaa6ba
commit
a016eeaba0
@ -60,16 +60,17 @@ public final class Long extends Number implements Comparable<Long> {
|
||||
}
|
||||
|
||||
boolean negative = v < 0;
|
||||
if (negative) v = -v;
|
||||
|
||||
int size = (negative ? 1 : 0);
|
||||
for (long n = v; n > 0; n /= radix) ++size;
|
||||
for (long n = v; n != 0; n /= radix) ++size;
|
||||
|
||||
char[] array = new char[size];
|
||||
|
||||
int i = array.length - 1;
|
||||
for (long n = v; n > 0; n /= radix) {
|
||||
for (long n = v; n != 0; n /= radix) {
|
||||
long digit = n % radix;
|
||||
if (negative) digit = -digit;
|
||||
|
||||
if (digit >= 0 && digit <= 9) {
|
||||
array[i] = (char) ('0' + digit);
|
||||
} else {
|
||||
|
@ -102,7 +102,10 @@ public class Misc {
|
||||
expect(foo > 0);
|
||||
}
|
||||
|
||||
expect(String.valueOf(25214903884l).equals("25214903884"));
|
||||
expect(String.valueOf(25214903884L).equals("25214903884"));
|
||||
|
||||
expect(String.valueOf(-9223372036854775808L).equals
|
||||
("-9223372036854775808"));
|
||||
|
||||
{ boolean p = true;
|
||||
int[] array = new int[] { 1, 2 };
|
||||
|
Loading…
Reference in New Issue
Block a user