1 /*
   2  * CDDL HEADER START
   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License, Version 1.0 only
   6  * (the "License").  You may not use this file except in compliance
   7  * with the License.
   8  *
   9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  10  * or http://www.opensolaris.org/os/licensing.
  11  * See the License for the specific language governing permissions
  12  * and limitations under the License.
  13  *
  14  * When distributing Covered Code, include this CDDL HEADER in each
  15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16  * If applicable, add the following below this CDDL HEADER, with the
  17  * fields enclosed by brackets "[]" replaced with your own identifying
  18  * information: Portions Copyright [yyyy] [name of copyright owner]
  19  *
  20  * CDDL HEADER END
  21  */
  22 /*      Copyright (c) 1988 AT&T     */
  23 /*        All Rights Reserved   */
  24 
  25 
  26 /*
  27  * Copyright 2014 Garrett D'Amore <garrett@damore.org>
  28  *
  29  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
  30  * Use is subject to license terms.
  31  */
  32 
  33 #ifndef _FLOAT_H
  34 #define _FLOAT_H
  35 
  36 #include <sys/feature_tests.h>
  37 
  38 #ifdef  __cplusplus
  39 extern "C" {
  40 #endif
  41 
  42 #if defined(__sparc)
  43 
  44 extern int __flt_rounds(void);
  45 #define FLT_ROUNDS      __flt_rounds()
  46 
  47 #else /* defined(__sparc) */
  48 
  49 extern int __fltrounds(void);
  50 
  51 #if defined(__amd64)
  52 #define FLT_ROUNDS      __fltrounds()
  53 #else   /* defined(__amd64) */
  54 extern int __flt_rounds;
  55 #define FLT_ROUNDS      __flt_rounds
  56 #endif  /* defined(__amd64) */
  57 #endif /* defined(__sparc) */
  58 
  59 /* Introduced in ISO/IEC 9899:1999 standard */
  60 #if defined(__EXTENSIONS__) || defined(_STDC_C99) || \
  61         (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX))
  62 #if defined(__FLT_EVAL_METHOD__)
  63 #define FLT_EVAL_METHOD __FLT_EVAL_METHOD__
  64 #else
  65 #define FLT_EVAL_METHOD -1
  66 #endif /* defined(__FLT_EVAL_METHOD__) */
  67 #endif /* defined(__EXTENSIONS__) || defined(_STDC_C99)... */
  68 
  69 #define FLT_RADIX       2
  70 #define FLT_MANT_DIG    24
  71 #define FLT_EPSILON     1.1920928955078125000000E-07F
  72 #define FLT_DIG         6
  73 #define FLT_MIN_EXP     (-125)
  74 #define FLT_MIN         1.1754943508222875079688E-38F
  75 #define FLT_MIN_10_EXP  (-37)
  76 #define FLT_MAX_EXP     (+128)
  77 #define FLT_MAX         3.4028234663852885981170E+38F
  78 #define FLT_MAX_10_EXP  (+38)
  79 
  80 #define DBL_MANT_DIG    53
  81 #define DBL_EPSILON     2.2204460492503130808473E-16
  82 #define DBL_DIG         15
  83 #define DBL_MIN_EXP     (-1021)
  84 #define DBL_MIN         2.2250738585072013830903E-308
  85 #define DBL_MIN_10_EXP  (-307)
  86 #define DBL_MAX_EXP     (+1024)
  87 #define DBL_MAX         1.7976931348623157081452E+308
  88 #define DBL_MAX_10_EXP  (+308)
  89 
  90 /* Introduced in ISO/IEC 9899:1999 standard */
  91 #if defined(__EXTENSIONS__) || defined(_STDC_C99) || \
  92         (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX))
  93 #if defined(__sparc)
  94 #define DECIMAL_DIG     36
  95 #elif defined(__i386) || defined(__amd64)
  96 #define DECIMAL_DIG     21
  97 #endif
  98 #endif /* defined(__EXTENSIONS__) || defined(_STDC_C99)... */
  99 
 100 
 101 #if defined(__i386) || defined(__amd64)
 102 
 103 /* Follows IEEE standards for 80-bit floating point */
 104 #define LDBL_MANT_DIG   64
 105 #define LDBL_EPSILON    1.0842021724855044340075E-19L
 106 #define LDBL_DIG        18
 107 #define LDBL_MIN_EXP    (-16381)
 108 #define LDBL_MIN        3.3621031431120935062627E-4932L
 109 #define LDBL_MIN_10_EXP (-4931)
 110 #define LDBL_MAX_EXP    (+16384)
 111 #define LDBL_MAX        1.1897314953572317650213E+4932L
 112 #define LDBL_MAX_10_EXP (+4932)
 113 
 114 #elif defined(__sparc)
 115 
 116 /* Follows IEEE standards for 128-bit floating point */
 117 #define LDBL_MANT_DIG   113
 118 #define LDBL_EPSILON    1.925929944387235853055977942584927319E-34L
 119 #define LDBL_DIG        33
 120 #define LDBL_MIN_EXP    (-16381)
 121 #define LDBL_MIN        3.362103143112093506262677817321752603E-4932L
 122 #define LDBL_MIN_10_EXP (-4931)
 123 #define LDBL_MAX_EXP    (+16384)
 124 #define LDBL_MAX        1.189731495357231765085759326628007016E+4932L
 125 #define LDBL_MAX_10_EXP (+4932)
 126 
 127 #else
 128 
 129 #error "Unknown architecture!"
 130 
 131 #endif
 132 
 133 
 134 #ifdef  __cplusplus
 135 }
 136 #endif
 137 
 138 #endif  /* _FLOAT_H */