[683] | 1 | /*
|
---|
| 2 | * *****************************************************************
|
---|
| 3 | * * *
|
---|
| 4 | * * Copyright (c) Digital Equipment Corporation, 1991, 1996 *
|
---|
| 5 | * * *
|
---|
| 6 | * * All Rights Reserved. Unpublished rights reserved under *
|
---|
| 7 | * * the copyright laws of the United States. *
|
---|
| 8 | * * *
|
---|
| 9 | * * The software contained on this media is proprietary to *
|
---|
| 10 | * * and embodies the confidential technology of Digital *
|
---|
| 11 | * * Equipment Corporation. Possession, use, duplication or *
|
---|
| 12 | * * dissemination of the software and media is authorized only *
|
---|
| 13 | * * pursuant to a valid written license from Digital Equipment *
|
---|
| 14 | * * Corporation. *
|
---|
| 15 | * * *
|
---|
| 16 | * * RESTRICTED RIGHTS LEGEND Use, duplication, or disclosure *
|
---|
| 17 | * * by the U.S. Government is subject to restrictions as set *
|
---|
| 18 | * * forth in Subparagraph (c)(1)(ii) of DFARS 252.227-7013, *
|
---|
| 19 | * * or in FAR 52.227-19, as applicable. *
|
---|
| 20 | * * *
|
---|
| 21 | * *****************************************************************
|
---|
| 22 | */
|
---|
| 23 | /*
|
---|
| 24 | * HISTORY
|
---|
| 25 | */
|
---|
| 26 | /*
|
---|
| 27 | * (c) Copyright 1990, OPEN SOFTWARE FOUNDATION, INC.
|
---|
| 28 | * ALL RIGHTS RESERVED
|
---|
| 29 | */
|
---|
| 30 | /*
|
---|
| 31 | * OSF/1 Release 1.0
|
---|
| 32 | */
|
---|
| 33 | /*
|
---|
| 34 | * RESTRICTED RIGHTS LEGEND
|
---|
| 35 | * Use, Duplication or Disclosure by the Government is subject to
|
---|
| 36 | * restrictions as set forth in paragraph (b)(3)(B) of the rights in
|
---|
| 37 | * Technical Data and Computer Software clause in DAR 7-104.9(a).
|
---|
| 38 | */
|
---|
| 39 |
|
---|
| 40 | /*
|
---|
| 41 | * COMPONENT_NAME: (values.h) header file of common values
|
---|
| 42 | *
|
---|
| 43 | * ORIGINS: 27
|
---|
| 44 | *
|
---|
| 45 | * (C) COPYRIGHT International Business Machines Corp. 1985, 1988, 1989
|
---|
| 46 | * All Rights Reserved
|
---|
| 47 | * Licensed Materials - Property of IBM
|
---|
| 48 | *
|
---|
| 49 | * US Government Users Restricted Rights - Use, duplication or
|
---|
| 50 | * disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
|
---|
| 51 | */
|
---|
| 52 |
|
---|
| 53 | #ifndef _VALUES_H_
|
---|
| 54 | #define _VALUES_H_
|
---|
| 55 |
|
---|
| 56 | #include <limits.h>
|
---|
| 57 |
|
---|
| 58 | #define BITSPERBYTE CHAR_BIT
|
---|
| 59 | #define BITS(type) (BITSPERBYTE * sizeof(type))
|
---|
| 60 |
|
---|
| 61 | /* short, regular and long ints with only the high-order bit turned on */
|
---|
| 62 | #define HIBITS ((short)(1 << BITS(short) - 1))
|
---|
| 63 | #define HIBITI (1U << BITS(int) - 1)
|
---|
| 64 | #define HIBITL (1UL << BITS(long) - 1)
|
---|
| 65 |
|
---|
| 66 | /* largest short, regular and long int */
|
---|
| 67 | #define MAXSHORT ((short)~HIBITS)
|
---|
| 68 | #define MAXINT ((int)~HIBITI)
|
---|
| 69 | #define MAXLONG ((long)~HIBITL)
|
---|
| 70 |
|
---|
| 71 | /* various values that describe the binary floating-point representation
|
---|
| 72 | * DMAXEXP - the maximum exponent of a double (as returned by frexp())
|
---|
| 73 | * FMAXEXP - the maximum exponent of a float (as returned by frexp())
|
---|
| 74 | * DMINEXP - the minimum exponent of a double (as returned by frexp())
|
---|
| 75 | * FMINEXP - the minimum exponent of a float (as returned by frexp())
|
---|
| 76 | * MAXDOUBLE - the largest double
|
---|
| 77 | ((_EXPBASE ** DMAXEXP) * (1 - (_EXPBASE ** -DSIGNIF)))
|
---|
| 78 | * MAXFLOAT - the largest float
|
---|
| 79 | ((_EXPBASE ** FMAXEXP) * (1 - (_EXPBASE ** -FSIGNIF)))
|
---|
| 80 | * MINDOUBLE - the smallest double (_EXPBASE ** (DMINEXP - 1))
|
---|
| 81 | * MINFLOAT - the smallest float (_EXPBASE ** (FMINEXP - 1))
|
---|
| 82 | * DSIGNIF - the number of significant bits in a double
|
---|
| 83 | * FSIGNIF - the number of significant bits in a float
|
---|
| 84 | * DMAXPOWTWO - the largest power of two exactly representable as a double
|
---|
| 85 | * FMAXPOWTWO - the largest power of two exactly representable as a float
|
---|
| 86 | * LN_MAXDOUBLE - the natural log of the largest double -- log(MAXDOUBLE)
|
---|
| 87 | * LN_MINDOUBLE - the natural log of the smallest double -- log(MINDOUBLE)
|
---|
| 88 | * _DEXPLEN - the number of bits for the exponent of a double (11)
|
---|
| 89 | * _FEXPLEN - the number of bits for the exponent of a float (8)
|
---|
| 90 | *
|
---|
| 91 | * These values are no longer defined, however, they are reference in other
|
---|
| 92 | * defines to show how they were calculated.
|
---|
| 93 | *
|
---|
| 94 | * _EXPBASE - the exponent base (2)
|
---|
| 95 | * _IEEE - 1 if IEEE standard representation is used (1)
|
---|
| 96 | * _LENBASE - the number of bits in the exponent base (1 for binary)
|
---|
| 97 | * _HIDDENBIT - 1 if high-significance bit of mantissa is implicit
|
---|
| 98 | */
|
---|
| 99 | /* these are for the IEEE format machines */
|
---|
| 100 | #define MAXDOUBLE 1.7976931348623157e+308
|
---|
| 101 |
|
---|
| 102 | #ifndef _MAXFLOAT
|
---|
| 103 | #define _MAXFLOAT
|
---|
| 104 | #define MAXFLOAT ((float)3.40282346638528860e+38)
|
---|
| 105 | #endif
|
---|
| 106 |
|
---|
| 107 | #define MINDOUBLE 4.94065645841246544e-324
|
---|
| 108 | #define MINFLOAT ((float)1.40129846432481707e-45)
|
---|
| 109 | #define _IEEE 1
|
---|
| 110 | #define _DEXPLEN 11
|
---|
| 111 | #define _HIDDENBIT 1
|
---|
| 112 | #define DMINEXP (-(DMAXEXP + DSIGNIF - _HIDDENBIT - 3))
|
---|
| 113 | #define FMINEXP (-(FMAXEXP + FSIGNIF - _HIDDENBIT - 3))
|
---|
| 114 | #define DSIGNIF (BITS(double) - _DEXPLEN + _HIDDENBIT - 1)
|
---|
| 115 | #define FSIGNIF (BITS(float) - _FEXPLEN + _HIDDENBIT - 1)
|
---|
| 116 | #define DMAXPOWTWO ((double)(1L << BITS(int) - 2) * \
|
---|
| 117 | (1L<<DSIGNIF-BITS(int)+1))
|
---|
| 118 | #define FMAXPOWTWO ((float)(1L << FSIGNIF - 1))
|
---|
| 119 | #define DMAXEXP ((1 << _DEXPLEN - 1) - 1 + _IEEE)
|
---|
| 120 | #define FMAXEXP ((1 << _FEXPLEN - 1) - 1 + _IEEE)
|
---|
| 121 | #define LN_MAXDOUBLE (M_LN2 * DMAXEXP)
|
---|
| 122 | #define LN_MINDOUBLE (M_LN2 * (DMINEXP - 1))
|
---|
| 123 |
|
---|
| 124 | #define _DEXPLEN 11
|
---|
| 125 | #define _FEXPLEN 8
|
---|
| 126 |
|
---|
| 127 | #define H_PREC (DSIGNIF % 2 ? (1L << DSIGNIF/2) * M_SQRT2 : 1L << DSIGNIF/2)
|
---|
| 128 |
|
---|
| 129 | #define X_PLOSS ((double)(long)(M_PI * H_PREC))
|
---|
| 130 | #define X_TLOSS (M_PI * DMAXPOWTWO)
|
---|
| 131 |
|
---|
| 132 | /* The next values are duplicated in math.h. They have to be */
|
---|
| 133 | /* here too for to keep from having to include math.h. */
|
---|
| 134 | #define M_LN2 6.9314718055994530942E-1 /*Hex 2^-1 * 1.62E42FEFA39EF */
|
---|
| 135 | //#define M_PI 3.1415926535897932385E0 /*Hex 2^ 1 * 1.921FB54442D18 */
|
---|
| 136 | #define M_SQRT2 1.4142135623730950488E0 /*Hex 2^ 0 * 1.6A09E667F3BCD */
|
---|
| 137 |
|
---|
| 138 | #endif /* _VALUES_H_ */
|
---|