Path: blob/master/test/jdk/java/lang/Math/DoubleConsts.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 double} type.25*/26public final class DoubleConsts {27/**28* Don't let anyone instantiate this class.29*/30private DoubleConsts() {}3132/**33* Bias used in representing a {@code double} exponent.34*/35public static final int EXP_BIAS = 1023;3637/**38* Bit mask to isolate the exponent field of a {@code double}.39*/40public static final long EXP_BIT_MASK = 0x7FF0000000000000L;4142/**43* Bit mask to isolate the sign bit of a {@code double}.44*/45public static final long SIGN_BIT_MASK = 0x8000000000000000L;4647/**48* Bit mask to isolate the significand field of a {@code double}.49*/50public static final long SIGNIF_BIT_MASK = 0x000FFFFFFFFFFFFFL;5152/**53* The number of logical bits in the significand of a54* {@code double} number, including the implicit bit.55*/56public static final int SIGNIFICAND_WIDTH = 53;5758/**59* The exponent the smallest positive {@code double}60* subnormal value would have if it could be normalized.61*/62public static final int MIN_SUB_EXPONENT = Double.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) == ~0L) &&69(((SIGN_BIT_MASK & EXP_BIT_MASK) == 0L) &&70((SIGN_BIT_MASK & SIGNIF_BIT_MASK) == 0L) &&71((EXP_BIT_MASK & SIGNIF_BIT_MASK) == 0L)));72}73}747576