Path: blob/master/test/jdk/java/lang/Math/FloatConsts.java
41149 views
/*1* Copyright (c) 2014, 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.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/**24* Common library for additional constants of the {@code float} type.25*/26public final class FloatConsts {27/**28* Don't let anyone instantiate this class.29*/30private FloatConsts() {}3132/**33* Bias used in representing a {@code float} exponent.34*/35public static final int EXP_BIAS = 127;3637/**38* Bit mask to isolate the exponent field of a {@code float}.39*/40public static final int EXP_BIT_MASK = 0x7F800000;4142/**43* Bit mask to isolate the sign bit of a {@code float}.44*/45public static final int SIGN_BIT_MASK = 0x80000000;4647/**48* Bit mask to isolate the significand field of a {@code float}.49*/50public static final int SIGNIF_BIT_MASK = 0x007FFFFF;5152/**53* The number of logical bits in the significand of a54* {@code float} number, including the implicit bit.55*/56public static final int SIGNIFICAND_WIDTH = 24;5758/**59* The exponent the smallest positive {@code float} subnormal60* value would have if it could be normalized.61*/62public static final int MIN_SUB_EXPONENT = Float.MIN_EXPONENT -63(SIGNIFICAND_WIDTH - 1);6465static {66// verify bit masks cover all bit positions and that the bit67// masks are non-overlapping68assert(((SIGN_BIT_MASK | EXP_BIT_MASK | SIGNIF_BIT_MASK) == ~0) &&69(((SIGN_BIT_MASK & EXP_BIT_MASK) == 0) &&70((SIGN_BIT_MASK & SIGNIF_BIT_MASK) == 0) &&71((EXP_BIT_MASK & SIGNIF_BIT_MASK) == 0)));72}73}747576