Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/sun/misc/FloatConsts.java
38829 views
/*1* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package sun.misc;2627/**28* This class contains additional constants documenting limits of the29* <code>float</code> type.30*31* @author Joseph D. Darcy32*/3334public class FloatConsts {35/**36* Don't let anyone instantiate this class.37*/38private FloatConsts() {}3940public static final float POSITIVE_INFINITY = java.lang.Float.POSITIVE_INFINITY;41public static final float NEGATIVE_INFINITY = java.lang.Float.NEGATIVE_INFINITY;42public static final float NaN = java.lang.Float.NaN;43public static final float MAX_VALUE = java.lang.Float.MAX_VALUE;44public static final float MIN_VALUE = java.lang.Float.MIN_VALUE;4546/**47* A constant holding the smallest positive normal value of type48* <code>float</code>, 2<sup>-126</sup>. It is equal to the value49* returned by <code>Float.intBitsToFloat(0x00800000)</code>.50*/51public static final float MIN_NORMAL = 1.17549435E-38f;5253/**54* The number of logical bits in the significand of a55* <code>float</code> number, including the implicit bit.56*/57public static final int SIGNIFICAND_WIDTH = 24;5859/**60* Maximum exponent a finite <code>float</code> number may have.61* It is equal to the value returned by62* <code>Math.ilogb(Float.MAX_VALUE)</code>.63*/64public static final int MAX_EXPONENT = 127;6566/**67* Minimum exponent a normalized <code>float</code> number may68* have. It is equal to the value returned by69* <code>Math.ilogb(Float.MIN_NORMAL)</code>.70*/71public static final int MIN_EXPONENT = -126;7273/**74* The exponent the smallest positive <code>float</code> subnormal75* value would have if it could be normalized. It is equal to the76* value returned by <code>FpUtils.ilogb(Float.MIN_VALUE)</code>.77*/78public static final int MIN_SUB_EXPONENT = MIN_EXPONENT -79(SIGNIFICAND_WIDTH - 1);8081/**82* Bias used in representing a <code>float</code> exponent.83*/84public static final int EXP_BIAS = 127;8586/**87* Bit mask to isolate the sign bit of a <code>float</code>.88*/89public static final int SIGN_BIT_MASK = 0x80000000;9091/**92* Bit mask to isolate the exponent field of a93* <code>float</code>.94*/95public static final int EXP_BIT_MASK = 0x7F800000;9697/**98* Bit mask to isolate the significand field of a99* <code>float</code>.100*/101public static final int SIGNIF_BIT_MASK = 0x007FFFFF;102103static {104// verify bit masks cover all bit positions and that the bit105// masks are non-overlapping106assert(((SIGN_BIT_MASK | EXP_BIT_MASK | SIGNIF_BIT_MASK) == ~0) &&107(((SIGN_BIT_MASK & EXP_BIT_MASK) == 0) &&108((SIGN_BIT_MASK & SIGNIF_BIT_MASK) == 0) &&109((EXP_BIT_MASK & SIGNIF_BIT_MASK) == 0)));110}111}112113114