test/java/util/Formatter/BasicDouble.java

Print this page
rev 7678 : 6476168: (fmt) Inconsistency formatting subnormal doubles with hexadecimal conversion
Summary: Update specification to match implementation.
Reviewed-by: darcy
Contributed-by: Brian Burkhalter <brian.burkhalter@oracle.com>


1302         // BigDecimal.
1303         //---------------------------------------------------------------------
1304         test("%a", "null", (Object)null);
1305         test("%.11a", "0x0.00000000000p0", 0.0);
1306         test(Locale.FRANCE, "%.11a", "0x0.00000000000p0", 0.0); // no localization
1307         test("%.1a", "0x0.0p0", 0.0);
1308         test("%.11a", "-0x0.00000000000p0", -0.0);
1309         test("%.1a", "-0x0.0p0", -0.0);
1310         test("%.11a", "0x1.00000000000p0", 1.0);
1311         test("%.1a", "0x1.0p0", 1.0);
1312         test("%.11a", "-0x1.00000000000p0", -1.0);
1313         test("%.1a", "-0x1.0p0", -1.0);
1314         test("%.11a", "0x1.80000000000p1", 3.0);
1315         test("%.1a", "0x1.8p1", 3.0);
1316         test("%.11a", "0x1.00000000000p-1022", DoubleConsts.MIN_NORMAL);
1317         test("%.1a", "0x1.0p-1022", DoubleConsts.MIN_NORMAL);
1318         test("%.11a", "0x1.00000000000p-1022",
1319              Math.nextDown(DoubleConsts.MIN_NORMAL));
1320         test("%.1a", "0x1.0p-1022",
1321              Math.nextDown(DoubleConsts.MIN_NORMAL));
1322         test("%.11a", "0x1.ffffffffffep-1023",
1323              Double.parseDouble("0x0.fffffffffffp-1022"));
1324         test("%.1a", "0x1.0p-1022",
1325              Double.parseDouble("0x0.fffffffffffp-1022"));
1326         test("%.30a", "0x0.000000000000100000000000000000p-1022", Double.MIN_VALUE);
1327         test("%.13a", "0x0.0000000000001p-1022", Double.MIN_VALUE);
1328         test("%.11a", "0x1.00000000000p-1074", Double.MIN_VALUE);
1329         test("%.1a", "0x1.0p-1074", Double.MIN_VALUE);
1330 
1331         test("%.11a", "0x1.08000000000p-1069",
1332              Double.MIN_VALUE + Double.MIN_VALUE*32);
1333         test("%.1a", "0x1.0p-1069",
1334              Double.MIN_VALUE + Double.MIN_VALUE*32);
1335         test("%.30a", "0x1.fffffffffffff00000000000000000p1023", Double.MAX_VALUE);
1336         test("%.13a", "0x1.fffffffffffffp1023", Double.MAX_VALUE);
1337         test("%.11a", "0x1.00000000000p1024", Double.MAX_VALUE);
1338         test("%.1a", "0x1.0p1024", Double.MAX_VALUE);
1339         test("%.11a", "0x1.18000000000p0", Double.parseDouble("0x1.18p0"));
1340         test("%.1a", "0x1.2p0", Double.parseDouble("0x1.18p0"));









































1341 
1342         test("%.11a", "0x1.18000000000p0",
1343              Double.parseDouble("0x1.180000000001p0"));
1344         test("%.1a", "0x1.2p0",
1345              Double.parseDouble("0x1.180000000001p0"));
1346         test("%.11a", "0x1.28000000000p0", Double.parseDouble("0x1.28p0"));
1347         test("%.1a", "0x1.2p0", Double.parseDouble("0x1.28p0"));
1348 
1349         test("%.11a", "0x1.28000000000p0",
1350              Double.parseDouble("0x1.280000000001p0"));
1351         test("%.1a", "0x1.3p0", Double.parseDouble("0x1.280000000001p0"));
1352 
1353 
1354         //---------------------------------------------------------------------
1355         // %f, %e, %g, %a - Boundaries
1356         //---------------------------------------------------------------------
1357 
1358 
1359 
1360 
1361 
1362 
1363 
1364 
1365 
1366 
1367 
1368 
1369 
1370 
1371 




1302         // BigDecimal.
1303         //---------------------------------------------------------------------
1304         test("%a", "null", (Object)null);
1305         test("%.11a", "0x0.00000000000p0", 0.0);
1306         test(Locale.FRANCE, "%.11a", "0x0.00000000000p0", 0.0); // no localization
1307         test("%.1a", "0x0.0p0", 0.0);
1308         test("%.11a", "-0x0.00000000000p0", -0.0);
1309         test("%.1a", "-0x0.0p0", -0.0);
1310         test("%.11a", "0x1.00000000000p0", 1.0);
1311         test("%.1a", "0x1.0p0", 1.0);
1312         test("%.11a", "-0x1.00000000000p0", -1.0);
1313         test("%.1a", "-0x1.0p0", -1.0);
1314         test("%.11a", "0x1.80000000000p1", 3.0);
1315         test("%.1a", "0x1.8p1", 3.0);
1316         test("%.11a", "0x1.00000000000p-1022", DoubleConsts.MIN_NORMAL);
1317         test("%.1a", "0x1.0p-1022", DoubleConsts.MIN_NORMAL);
1318         test("%.11a", "0x1.00000000000p-1022",
1319              Math.nextDown(DoubleConsts.MIN_NORMAL));
1320         test("%.1a", "0x1.0p-1022",
1321              Math.nextDown(DoubleConsts.MIN_NORMAL));
1322         test("%.11a", "0x1.ffffffffffep-1023", 0x0.fffffffffffp-1022);
1323         test("%.1a", "0x1.0p-1022", 0x0.fffffffffffp-1022);


1324         test("%.30a", "0x0.000000000000100000000000000000p-1022", Double.MIN_VALUE);
1325         test("%.13a", "0x0.0000000000001p-1022", Double.MIN_VALUE);
1326         test("%.11a", "0x1.00000000000p-1074", Double.MIN_VALUE);
1327         test("%.1a", "0x1.0p-1074", Double.MIN_VALUE);
1328 
1329         test("%.11a", "0x1.08000000000p-1069",
1330              Double.MIN_VALUE + Double.MIN_VALUE*32);
1331         test("%.1a", "0x1.0p-1069",
1332              Double.MIN_VALUE + Double.MIN_VALUE*32);
1333         test("%.30a", "0x1.fffffffffffff00000000000000000p1023", Double.MAX_VALUE);
1334         test("%.13a", "0x1.fffffffffffffp1023", Double.MAX_VALUE);
1335         test("%.11a", "0x1.00000000000p1024", Double.MAX_VALUE);
1336         test("%.1a", "0x1.0p1024", Double.MAX_VALUE);
1337         test("%.11a", "0x1.18000000000p0", 0x1.18p0);
1338         test("%.1a", "0x1.2p0", 0x1.18p0);
1339 
1340         test("%.11a", "0x1.18000000000p0", 0x1.180000000001p0);
1341         test("%.1a", "0x1.2p0", 0x1.180000000001p0);
1342         test("%.11a", "0x1.28000000000p0", 0x1.28p0);
1343         test("%.1a", "0x1.2p0", 0x1.28p0);
1344 
1345         test("%.11a", "0x1.28000000000p0", 0x1.280000000001p0);
1346         test("%.1a", "0x1.3p0", 0x1.280000000001p0);
1347 
1348         test("%a", "0x0.123p-1022", 0x0.123p-1022);
1349         test("%1.3a", "0x1.230p-1026", 0x0.123p-1022);
1350         test("%1.12a", "0x1.230000000000p-1026", 0x0.123p-1022);
1351         test("%1.15a", "0x0.123000000000000p-1022", 0x0.123p-1022);
1352         test("%1.5a", "0x1.00000p-1074", 0x0.0000000000001p-1022);
1353         test("%1.7a", "0x1.0000000p-1022", 0x0.fffffffffffffp-1022);
1354 
1355         test("%1.6a", "0x1.230000p-1026", 0x0.123000057p-1022);
1356         test("%1.7a", "0x1.2300005p-1026", 0x0.123000057p-1022);
1357         test("%1.8a", "0x1.23000057p-1026", 0x0.123000057p-1022);
1358         test("%1.9a", "0x1.230000570p-1026", 0x0.123000057p-1022);
1359 
1360         test("%1.6a", "0x1.230000p-1026", 0x0.123000058p-1022);
1361         test("%1.7a", "0x1.2300006p-1026", 0x0.123000058p-1022);
1362         test("%1.8a", "0x1.23000058p-1026", 0x0.123000058p-1022);
1363         test("%1.9a", "0x1.230000580p-1026", 0x0.123000058p-1022);
1364 
1365         test("%1.6a", "0x1.230000p-1026", 0x0.123000059p-1022);
1366         test("%1.7a", "0x1.2300006p-1026", 0x0.123000059p-1022);
1367         test("%1.8a", "0x1.23000059p-1026", 0x0.123000059p-1022);
1368         test("%1.9a", "0x1.230000590p-1026", 0x0.123000059p-1022);
1369 
1370         test("%1.4a", "0x1.0000p-1022", Math.nextDown(Double.MIN_NORMAL));
1371 
1372         test("%a", "0x1.fffffffffffffp1023", Double.MAX_VALUE);
1373         test("%1.1a", "0x1.0p1024", Double.MAX_VALUE);
1374         test("%1.2a", "0x1.00p1024", Double.MAX_VALUE);
1375         test("%1.6a", "0x1.000000p1024", Double.MAX_VALUE);
1376         test("%1.9a", "0x1.000000000p1024", Double.MAX_VALUE);
1377         test("%1.11a", "0x1.00000000000p1024", Double.MAX_VALUE);
1378         test("%1.12a", "0x1.000000000000p1024", Double.MAX_VALUE);
1379         test("%1.13a", "0x1.fffffffffffffp1023", Double.MAX_VALUE);
1380 










1381 
1382 
1383         //---------------------------------------------------------------------
1384         // %f, %e, %g, %a - Boundaries
1385         //---------------------------------------------------------------------
1386 
1387 
1388 
1389 
1390 
1391 
1392 
1393 
1394 
1395 
1396 
1397 
1398 
1399 
1400