1 /*
2  * Copyright (c) 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 package test.java.lang.Math;
24 
25 import org.testng.annotations.Test;
26 import org.testng.Assert;
27 
28 /**
29  * Common library for additional constants of the {@code float} type.
30  */
31 public final class FloatConsts {
32 
33     /**
34      * Don't let anyone instantiate this class.
35      */
FloatConsts()36     private FloatConsts() {
37     }
38 
39     /**
40      * Bias used in representing a {@code float} exponent.
41      */
42     public static final int EXP_BIAS = jdk.internal.math.FloatConsts.EXP_BIAS;
43 
44     /**
45      * Bit mask to isolate the exponent field of a {@code float}.
46      */
47     public static final int EXP_BIT_MASK = jdk.internal.math.FloatConsts.EXP_BIT_MASK;
48 
49     /**
50      * Bit mask to isolate the sign bit of a {@code float}.
51      */
52     public static final int SIGN_BIT_MASK = jdk.internal.math.FloatConsts.SIGN_BIT_MASK;
53 
54     /**
55      * Bit mask to isolate the significand field of a {@code float}.
56      */
57     public static final int SIGNIF_BIT_MASK = jdk.internal.math.FloatConsts.SIGNIF_BIT_MASK;
58 
59     /**
60      * The number of logical bits in the significand of a {@code float} number, including the
61      * implicit bit.
62      */
63     public static final int SIGNIFICAND_WIDTH = jdk.internal.math.FloatConsts.SIGNIFICAND_WIDTH;
64 
65     /**
66      * The exponent the smallest positive {@code float} subnormal value would have if it could be
67      * normalized.
68      */
69     public static final int MIN_SUB_EXPONENT = jdk.internal.math.FloatConsts.MIN_SUB_EXPONENT;
70 
71     @Test
testFloatConstants()72     public void testFloatConstants() {
73         Assert.assertEquals((SIGN_BIT_MASK | EXP_BIT_MASK | SIGNIF_BIT_MASK), ~0);
74         Assert.assertEquals((SIGN_BIT_MASK & EXP_BIT_MASK), 0);
75         Assert.assertEquals((SIGN_BIT_MASK & SIGNIF_BIT_MASK), 0);
76         Assert.assertEquals((EXP_BIT_MASK & SIGNIF_BIT_MASK), 0);
77     }
78 }
79