1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright 1989 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate /* Copyright (c) 1984 AT&T */ 28*7c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*7c478bd9Sstevel@tonic-gate 32*7c478bd9Sstevel@tonic-gate #ifndef _values_h 33*7c478bd9Sstevel@tonic-gate #define _values_h 34*7c478bd9Sstevel@tonic-gate 35*7c478bd9Sstevel@tonic-gate /* These values work with any binary representation of integers 36*7c478bd9Sstevel@tonic-gate * where the high-order bit contains the sign. */ 37*7c478bd9Sstevel@tonic-gate 38*7c478bd9Sstevel@tonic-gate /* a number used normally for size of a shift */ 39*7c478bd9Sstevel@tonic-gate #if gcos 40*7c478bd9Sstevel@tonic-gate #define BITSPERBYTE 9 41*7c478bd9Sstevel@tonic-gate #else 42*7c478bd9Sstevel@tonic-gate #define BITSPERBYTE 8 43*7c478bd9Sstevel@tonic-gate #endif 44*7c478bd9Sstevel@tonic-gate #define BITS(type) (BITSPERBYTE * (int)sizeof(type)) 45*7c478bd9Sstevel@tonic-gate 46*7c478bd9Sstevel@tonic-gate /* short, regular and long ints with only the high-order bit turned on */ 47*7c478bd9Sstevel@tonic-gate #define HIBITS ((short)(1 << BITS(short) - 1)) 48*7c478bd9Sstevel@tonic-gate #define HIBITI (1U << BITS(int) - 1) 49*7c478bd9Sstevel@tonic-gate #define HIBITL (1UL << BITS(long) - 1) 50*7c478bd9Sstevel@tonic-gate 51*7c478bd9Sstevel@tonic-gate /* largest short, regular and long int */ 52*7c478bd9Sstevel@tonic-gate #define MAXSHORT ((short)~HIBITS) 53*7c478bd9Sstevel@tonic-gate #define MAXINT ((int)~HIBITI) 54*7c478bd9Sstevel@tonic-gate #define MAXLONG ((long)~HIBITL) 55*7c478bd9Sstevel@tonic-gate 56*7c478bd9Sstevel@tonic-gate /* various values that describe the binary floating-point representation 57*7c478bd9Sstevel@tonic-gate * _EXPBASE - the exponent base 58*7c478bd9Sstevel@tonic-gate * DMAXEXP - the maximum exponent of a double (as returned by frexp()) 59*7c478bd9Sstevel@tonic-gate * FMAXEXP - the maximum exponent of a float (as returned by frexp()) 60*7c478bd9Sstevel@tonic-gate * DMINEXP - the minimum exponent of a double (as returned by frexp()) 61*7c478bd9Sstevel@tonic-gate * FMINEXP - the minimum exponent of a float (as returned by frexp()) 62*7c478bd9Sstevel@tonic-gate * MAXDOUBLE - the largest double 63*7c478bd9Sstevel@tonic-gate ((_EXPBASE ** DMAXEXP) * (1 - (_EXPBASE ** -DSIGNIF))) 64*7c478bd9Sstevel@tonic-gate * MAXFLOAT - the largest float 65*7c478bd9Sstevel@tonic-gate ((_EXPBASE ** FMAXEXP) * (1 - (_EXPBASE ** -FSIGNIF))) 66*7c478bd9Sstevel@tonic-gate * MINDOUBLE - the smallest double (_EXPBASE ** (DMINEXP - 1)) 67*7c478bd9Sstevel@tonic-gate * MINFLOAT - the smallest float (_EXPBASE ** (FMINEXP - 1)) 68*7c478bd9Sstevel@tonic-gate * DSIGNIF - the number of significant bits in a double 69*7c478bd9Sstevel@tonic-gate * FSIGNIF - the number of significant bits in a float 70*7c478bd9Sstevel@tonic-gate * DMAXPOWTWO - the largest power of two exactly representable as a double 71*7c478bd9Sstevel@tonic-gate * FMAXPOWTWO - the largest power of two exactly representable as a float 72*7c478bd9Sstevel@tonic-gate * _IEEE - 1 if IEEE standard representation is used 73*7c478bd9Sstevel@tonic-gate * _DEXPLEN - the number of bits for the exponent of a double 74*7c478bd9Sstevel@tonic-gate * _FEXPLEN - the number of bits for the exponent of a float 75*7c478bd9Sstevel@tonic-gate * _HIDDENBIT - 1 if high-significance bit of mantissa is implicit 76*7c478bd9Sstevel@tonic-gate * LN_MAXDOUBLE - the natural log of the largest double -- log(MAXDOUBLE) 77*7c478bd9Sstevel@tonic-gate * LN_MINDOUBLE - the natural log of the smallest double -- log(MINDOUBLE) 78*7c478bd9Sstevel@tonic-gate * LN_MAXFLOAT - the natural log of the largest float 79*7c478bd9Sstevel@tonic-gate * LN_MINFLOAT - the natural log of the smallest float 80*7c478bd9Sstevel@tonic-gate */ 81*7c478bd9Sstevel@tonic-gate #if u3b || u3b5 || sun 82*7c478bd9Sstevel@tonic-gate #define MAXDOUBLE 1.797693134862315708e+308 83*7c478bd9Sstevel@tonic-gate #define MAXFLOAT ((float)3.40282346638528860e+38) 84*7c478bd9Sstevel@tonic-gate #define MINDOUBLE 4.94065645841246544e-324 85*7c478bd9Sstevel@tonic-gate #define MINFLOAT ((float)1.40129846432481707e-45) 86*7c478bd9Sstevel@tonic-gate #define _IEEE 1 87*7c478bd9Sstevel@tonic-gate #define _DEXPLEN 11 88*7c478bd9Sstevel@tonic-gate #define _HIDDENBIT 1 89*7c478bd9Sstevel@tonic-gate #define DMINEXP (-(DMAXEXP + DSIGNIF - _HIDDENBIT - 3)) 90*7c478bd9Sstevel@tonic-gate #define FMINEXP (-(FMAXEXP + FSIGNIF - _HIDDENBIT - 3)) 91*7c478bd9Sstevel@tonic-gate #define LN_MAXFLOAT 8.8722839052068e+01 92*7c478bd9Sstevel@tonic-gate #define LN_MINFLOAT -1.03278929903432e+02 93*7c478bd9Sstevel@tonic-gate #endif 94*7c478bd9Sstevel@tonic-gate #if pdp11 || vax 95*7c478bd9Sstevel@tonic-gate #define MAXDOUBLE 1.701411834604692293e+38 96*7c478bd9Sstevel@tonic-gate #define MAXFLOAT ((float)1.701411733192644299e+38) 97*7c478bd9Sstevel@tonic-gate /* The following is kludged because the PDP-11 compilers botch the simple form. 98*7c478bd9Sstevel@tonic-gate The kludge causes the constant to be computed at run-time on the PDP-11, 99*7c478bd9Sstevel@tonic-gate even though it is still "folded" at compile-time on the VAX. */ 100*7c478bd9Sstevel@tonic-gate #define MINDOUBLE (0.01 * 2.938735877055718770e-37) 101*7c478bd9Sstevel@tonic-gate #define MINFLOAT ((float)MINDOUBLE) 102*7c478bd9Sstevel@tonic-gate #define _IEEE 0 103*7c478bd9Sstevel@tonic-gate #define _DEXPLEN 8 104*7c478bd9Sstevel@tonic-gate #define _HIDDENBIT 1 105*7c478bd9Sstevel@tonic-gate #define DMINEXP (-DMAXEXP) 106*7c478bd9Sstevel@tonic-gate #define FMINEXP (-FMAXEXP) 107*7c478bd9Sstevel@tonic-gate #endif 108*7c478bd9Sstevel@tonic-gate #if gcos 109*7c478bd9Sstevel@tonic-gate #define MAXDOUBLE 1.7014118346046923171e+38 110*7c478bd9Sstevel@tonic-gate #define MAXFLOAT ((float)1.7014118219281863150e+38) 111*7c478bd9Sstevel@tonic-gate #define MINDOUBLE 2.9387358770557187699e-39 112*7c478bd9Sstevel@tonic-gate #define MINFLOAT ((float)MINDOUBLE) 113*7c478bd9Sstevel@tonic-gate #define _IEEE 0 114*7c478bd9Sstevel@tonic-gate #define _DEXPLEN 8 115*7c478bd9Sstevel@tonic-gate #define _HIDDENBIT 0 116*7c478bd9Sstevel@tonic-gate #define DMINEXP (-(DMAXEXP + 1)) 117*7c478bd9Sstevel@tonic-gate #define FMINEXP (-(FMAXEXP + 1)) 118*7c478bd9Sstevel@tonic-gate #endif 119*7c478bd9Sstevel@tonic-gate #if u370 120*7c478bd9Sstevel@tonic-gate #define _LENBASE 4 121*7c478bd9Sstevel@tonic-gate #else 122*7c478bd9Sstevel@tonic-gate #define _LENBASE 1 123*7c478bd9Sstevel@tonic-gate #endif 124*7c478bd9Sstevel@tonic-gate #define _EXPBASE (1 << _LENBASE) 125*7c478bd9Sstevel@tonic-gate #define _FEXPLEN 8 126*7c478bd9Sstevel@tonic-gate #define DSIGNIF (BITS(double) - _DEXPLEN + _HIDDENBIT - 1) 127*7c478bd9Sstevel@tonic-gate #define FSIGNIF (BITS(float) - _FEXPLEN + _HIDDENBIT - 1) 128*7c478bd9Sstevel@tonic-gate #define DMAXPOWTWO ((double)(1L << BITS(long) - 2) * \ 129*7c478bd9Sstevel@tonic-gate (1L << DSIGNIF - BITS(long) + 1)) 130*7c478bd9Sstevel@tonic-gate #define FMAXPOWTWO ((float)(1L << FSIGNIF - 1)) 131*7c478bd9Sstevel@tonic-gate #define DMAXEXP ((1 << _DEXPLEN - 1) - 1 + _IEEE) 132*7c478bd9Sstevel@tonic-gate #define FMAXEXP ((1 << _FEXPLEN - 1) - 1 + _IEEE) 133*7c478bd9Sstevel@tonic-gate #define LN_MAXDOUBLE (M_LN2 * DMAXEXP) 134*7c478bd9Sstevel@tonic-gate #define LN_MINDOUBLE (M_LN2 * (DMINEXP - 1)) 135*7c478bd9Sstevel@tonic-gate 136*7c478bd9Sstevel@tonic-gate #define H_PREC (DSIGNIF % 2 ? (1L << DSIGNIF/2) * M_SQRT2 : 1L << DSIGNIF/2) 137*7c478bd9Sstevel@tonic-gate #define X_EPS (1.0/H_PREC) 138*7c478bd9Sstevel@tonic-gate #define X_PLOSS ((double)(long)(M_PI * H_PREC)) 139*7c478bd9Sstevel@tonic-gate #define X_TLOSS (M_PI * DMAXPOWTWO) 140*7c478bd9Sstevel@tonic-gate #define M_LN2 0.69314718055994530942 141*7c478bd9Sstevel@tonic-gate #define M_PI 3.14159265358979323846 142*7c478bd9Sstevel@tonic-gate #define M_SQRT2 1.41421356237309504880 143*7c478bd9Sstevel@tonic-gate #define MAXBEXP DMAXEXP /* for backward compatibility */ 144*7c478bd9Sstevel@tonic-gate #define MINBEXP DMINEXP /* for backward compatibility */ 145*7c478bd9Sstevel@tonic-gate #define MAXPOWTWO DMAXPOWTWO /* for backward compatibility */ 146*7c478bd9Sstevel@tonic-gate 147*7c478bd9Sstevel@tonic-gate #endif /*!_values_h*/ 148