1 /*
2 * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /* Type-specific source code for unit test
25 *
26 * Regenerate the BasicX classes via genBasic.sh whenever this file changes.
27 * We check in the generated source files so that the test tree can be used
28 * independently of the rest of the source tree.
29 */
30
31 // -- This file was mechanically generated: Do not edit! -- //
32
33 import java.io.*;
34 import java.math.BigDecimal;
35 import java.math.BigInteger;
36 import java.text.DateFormatSymbols;
37 import java.util.*;
38
39 import jdk.internal.math.DoubleConsts;
40
41
42 import static java.util.Calendar.*;
43
44
45
46
47
48 public class BasicDouble extends Basic {
49
50 private static void test(String fs, String exp, Object ... args) {
51 Formatter f = new Formatter(new StringBuilder(), Locale.US);
52 f.format(fs, args);
53 ck(fs, exp, f.toString());
54
55 f = new Formatter(new StringBuilder(), Locale.US);
56 f.format("foo " + fs + " bar", args);
57 ck(fs, "foo " + exp + " bar", f.toString());
58 }
59
60 private static void test(Locale l, String fs, String exp, Object ... args)
61 {
1342
1343
1344 //---------------------------------------------------------------------
1345 // %a
1346 //
1347 // Floating-point conversions applicable to float, double, and
1348 // BigDecimal.
1349 //---------------------------------------------------------------------
1350 test("%a", "null", (Object)null);
1351 test("%.11a", "0x0.00000000000p0", 0.0);
1352 test(Locale.FRANCE, "%.11a", "0x0.00000000000p0", 0.0); // no localization
1353 test("%.1a", "0x0.0p0", 0.0);
1354 test("%.11a", "-0x0.00000000000p0", -0.0);
1355 test("%.1a", "-0x0.0p0", -0.0);
1356 test("%.11a", "0x1.00000000000p0", 1.0);
1357 test("%.1a", "0x1.0p0", 1.0);
1358 test("%.11a", "-0x1.00000000000p0", -1.0);
1359 test("%.1a", "-0x1.0p0", -1.0);
1360 test("%.11a", "0x1.80000000000p1", 3.0);
1361 test("%.1a", "0x1.8p1", 3.0);
1362 test("%.11a", "0x1.00000000000p-1022", DoubleConsts.MIN_NORMAL);
1363 test("%.1a", "0x1.0p-1022", DoubleConsts.MIN_NORMAL);
1364 test("%.11a", "0x1.00000000000p-1022",
1365 Math.nextDown(DoubleConsts.MIN_NORMAL));
1366 test("%.1a", "0x1.0p-1022",
1367 Math.nextDown(DoubleConsts.MIN_NORMAL));
1368 test("%.11a", "0x1.ffffffffffep-1023", 0x0.fffffffffffp-1022);
1369 test("%.1a", "0x1.0p-1022", 0x0.fffffffffffp-1022);
1370 test("%.30a", "0x0.000000000000100000000000000000p-1022", Double.MIN_VALUE);
1371 test("%.13a", "0x0.0000000000001p-1022", Double.MIN_VALUE);
1372 test("%.11a", "0x1.00000000000p-1074", Double.MIN_VALUE);
1373 test("%.1a", "0x1.0p-1074", Double.MIN_VALUE);
1374
1375 test("%.11a", "0x1.08000000000p-1069",
1376 Double.MIN_VALUE + Double.MIN_VALUE*32);
1377 test("%.1a", "0x1.0p-1069",
1378 Double.MIN_VALUE + Double.MIN_VALUE*32);
1379 test("%.30a", "0x1.fffffffffffff00000000000000000p1023", Double.MAX_VALUE);
1380 test("%.13a", "0x1.fffffffffffffp1023", Double.MAX_VALUE);
1381 test("%.11a", "0x1.00000000000p1024", Double.MAX_VALUE);
1382 test("%.1a", "0x1.0p1024", Double.MAX_VALUE);
1383 test("%.11a", "0x1.18000000000p0", 0x1.18p0);
1384 test("%.1a", "0x1.2p0", 0x1.18p0);
1385
1386 test("%.11a", "0x1.18000000000p0", 0x1.180000000001p0);
1387 test("%.1a", "0x1.2p0", 0x1.180000000001p0);
|
1 /*
2 * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /* Type-specific source code for unit test
25 *
26 * Regenerate the BasicX classes via genBasic.sh whenever this file changes.
27 * We check in the generated source files so that the test tree can be used
28 * independently of the rest of the source tree.
29 */
30
31 // -- This file was mechanically generated: Do not edit! -- //
32
33 import java.io.*;
34 import java.math.BigDecimal;
35 import java.math.BigInteger;
36 import java.text.DateFormatSymbols;
37 import java.util.*;
38
39 import static java.util.Calendar.*;
40
41
42
43
44
45 public class BasicDouble extends Basic {
46
47 private static void test(String fs, String exp, Object ... args) {
48 Formatter f = new Formatter(new StringBuilder(), Locale.US);
49 f.format(fs, args);
50 ck(fs, exp, f.toString());
51
52 f = new Formatter(new StringBuilder(), Locale.US);
53 f.format("foo " + fs + " bar", args);
54 ck(fs, "foo " + exp + " bar", f.toString());
55 }
56
57 private static void test(Locale l, String fs, String exp, Object ... args)
58 {
1339
1340
1341 //---------------------------------------------------------------------
1342 // %a
1343 //
1344 // Floating-point conversions applicable to float, double, and
1345 // BigDecimal.
1346 //---------------------------------------------------------------------
1347 test("%a", "null", (Object)null);
1348 test("%.11a", "0x0.00000000000p0", 0.0);
1349 test(Locale.FRANCE, "%.11a", "0x0.00000000000p0", 0.0); // no localization
1350 test("%.1a", "0x0.0p0", 0.0);
1351 test("%.11a", "-0x0.00000000000p0", -0.0);
1352 test("%.1a", "-0x0.0p0", -0.0);
1353 test("%.11a", "0x1.00000000000p0", 1.0);
1354 test("%.1a", "0x1.0p0", 1.0);
1355 test("%.11a", "-0x1.00000000000p0", -1.0);
1356 test("%.1a", "-0x1.0p0", -1.0);
1357 test("%.11a", "0x1.80000000000p1", 3.0);
1358 test("%.1a", "0x1.8p1", 3.0);
1359 test("%.11a", "0x1.00000000000p-1022", Double.MIN_NORMAL);
1360 test("%.1a", "0x1.0p-1022", Double.MIN_NORMAL);
1361 test("%.11a", "0x1.00000000000p-1022",
1362 Math.nextDown(Double.MIN_NORMAL));
1363 test("%.1a", "0x1.0p-1022",
1364 Math.nextDown(Double.MIN_NORMAL));
1365 test("%.11a", "0x1.ffffffffffep-1023", 0x0.fffffffffffp-1022);
1366 test("%.1a", "0x1.0p-1022", 0x0.fffffffffffp-1022);
1367 test("%.30a", "0x0.000000000000100000000000000000p-1022", Double.MIN_VALUE);
1368 test("%.13a", "0x0.0000000000001p-1022", Double.MIN_VALUE);
1369 test("%.11a", "0x1.00000000000p-1074", Double.MIN_VALUE);
1370 test("%.1a", "0x1.0p-1074", Double.MIN_VALUE);
1371
1372 test("%.11a", "0x1.08000000000p-1069",
1373 Double.MIN_VALUE + Double.MIN_VALUE*32);
1374 test("%.1a", "0x1.0p-1069",
1375 Double.MIN_VALUE + Double.MIN_VALUE*32);
1376 test("%.30a", "0x1.fffffffffffff00000000000000000p1023", Double.MAX_VALUE);
1377 test("%.13a", "0x1.fffffffffffffp1023", Double.MAX_VALUE);
1378 test("%.11a", "0x1.00000000000p1024", Double.MAX_VALUE);
1379 test("%.1a", "0x1.0p1024", Double.MAX_VALUE);
1380 test("%.11a", "0x1.18000000000p0", 0x1.18p0);
1381 test("%.1a", "0x1.2p0", 0x1.18p0);
1382
1383 test("%.11a", "0x1.18000000000p0", 0x1.180000000001p0);
1384 test("%.1a", "0x1.2p0", 0x1.180000000001p0);
|