jdk/src/share/classes/sun/misc/DoubleConsts.java
author duke
Sat, 01 Dec 2007 00:00:00 +0000
changeset 2 90ce3da70b43
child 5506 202f599c92aa
permissions -rw-r--r--
Initial load
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * Copyright 2003 Sun Microsystems, Inc.  All Rights Reserved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package sun.misc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 * This class contains additional constants documenting limits of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 * <code>double</code> type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * @author Joseph D. Darcy
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
public class DoubleConsts {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
     * Don't let anyone instantiate this class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
    private DoubleConsts() {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
    public static final double POSITIVE_INFINITY = java.lang.Double.POSITIVE_INFINITY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
    public static final double NEGATIVE_INFINITY = java.lang.Double.NEGATIVE_INFINITY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
    public static final double NaN = java.lang.Double.NaN;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
    public static final double MAX_VALUE = java.lang.Double.MAX_VALUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    public static final double MIN_VALUE = java.lang.Double.MIN_VALUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
     * A constant holding the smallest positive normal value of type
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
     * <code>double</code>, 2<sup>-1022</sup>.  It is equal to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
     * value returned by
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
     * <code>Double.longBitsToDouble(0x0010000000000000L)</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
     * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    public static final double  MIN_NORMAL      = 2.2250738585072014E-308;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
     * The number of logical bits in the significand of a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     * <code>double</code> number, including the implicit bit.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    public static final int SIGNIFICAND_WIDTH   = 53;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     * Maximum exponent a finite <code>double</code> number may have.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     * It is equal to the value returned by
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     * <code>Math.ilogb(Double.MAX_VALUE)</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    public static final int     MAX_EXPONENT    = 1023;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * Minimum exponent a normalized <code>double</code> number may
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     * have.  It is equal to the value returned by
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     * <code>Math.ilogb(Double.MIN_NORMAL)</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    public static final int     MIN_EXPONENT    = -1022;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     * The exponent the smallest positive <code>double</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     * subnormal value would have if it could be normalized.  It is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * equal to the value returned by
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * <code>FpUtils.ilogb(Double.MIN_VALUE)</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    public static final int     MIN_SUB_EXPONENT = MIN_EXPONENT -
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
                                                   (SIGNIFICAND_WIDTH - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * Bias used in representing a <code>double</code> exponent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    public static final int     EXP_BIAS        = 1023;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * Bit mask to isolate the sign bit of a <code>double</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    public static final long    SIGN_BIT_MASK   = 0x8000000000000000L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * Bit mask to isolate the exponent field of a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * <code>double</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    public static final long    EXP_BIT_MASK    = 0x7FF0000000000000L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * Bit mask to isolate the significand field of a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * <code>double</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    public static final long    SIGNIF_BIT_MASK = 0x000FFFFFFFFFFFFFL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    static {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        // verify bit masks cover all bit positions and that the bit
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        // masks are non-overlapping
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        assert(((SIGN_BIT_MASK | EXP_BIT_MASK | SIGNIF_BIT_MASK) == ~0L) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
               (((SIGN_BIT_MASK & EXP_BIT_MASK) == 0L) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
                ((SIGN_BIT_MASK & SIGNIF_BIT_MASK) == 0L) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
                ((EXP_BIT_MASK & SIGNIF_BIT_MASK) == 0L)));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
}