The following delightful java program:
public class Bug {
public static void main (String[] args) {
String doubleMinVal =
"0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004940656458412465441765687928682213723650598026143247644255856825006755072702087518652998363616359923797965646954457177309266567103559397963987747960107818781263007131903114045278458171678489821036887186360569987307230500063874091535649843873124733972731696151400317153853980741262385655911710266585566867681870395603106249319452715914924553293054565444011274801297099995419319894090804165633245247571478690147267801593552386115501348035264934720193790268107107491703332226844753335720832431936092382893458368060106011506169809753078342277318329247904982524730776375927247874656084778203734469699533647017972677717585125660551199131504891101451037862738167250955837389733598993664809941164205702637090279242767544565229087538682506419718265533447265625";
double minVal = Double.valueOf(doubleMinVal).doubleValue();
System.out.println("Double: " + minVal);
System.out.println("Long bits: " + Double.doubleToLongBits(minVal));
}
}
produces this (correct) output on Solaris:
Double: 4.9E-324
Long bits: 1
and this (bogus) output on win32:
Double: 1.0E-323
Long bits: 2
public class Bug {
public static void main (String[] args) {
String doubleMinVal =
"0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004940656458412465441765687928682213723650598026143247644255856825006755072702087518652998363616359923797965646954457177309266567103559397963987747960107818781263007131903114045278458171678489821036887186360569987307230500063874091535649843873124733972731696151400317153853980741262385655911710266585566867681870395603106249319452715914924553293054565444011274801297099995419319894090804165633245247571478690147267801593552386115501348035264934720193790268107107491703332226844753335720832431936092382893458368060106011506169809753078342277318329247904982524730776375927247874656084778203734469699533647017972677717585125660551199131504891101451037862738167250955837389733598993664809941164205702637090279242767544565229087538682506419718265533447265625";
double minVal = Double.valueOf(doubleMinVal).doubleValue();
System.out.println("Double: " + minVal);
System.out.println("Long bits: " + Double.doubleToLongBits(minVal));
}
}
produces this (correct) output on Solaris:
Double: 4.9E-324
Long bits: 1
and this (bogus) output on win32:
Double: 1.0E-323
Long bits: 2
- duplicates
-
JDK-4032777 Win32 double reader can't handle full range of values
-
- Closed
-
- relates to
-
JDK-4031497 java.math.BigDecimal constructor(double) works wrong on Win32
-
- Closed
-