1 /* `HUGE_VAL' constants for IEEE 754 machines (where it is infinity).
2 Used by <stdlib.h> and <math.h> functions for overflow.
3 Copyright (C) 1992, 1995, 1996, 1997, 1999, 2000 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public License as
8 published by the Free Software Foundation; either version 2 of the
9 License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
16 You should have received a copy of the GNU Library General Public
17 License along with the GNU C Library; see the file COPYING.LIB. If not,
18 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
22 # error "Never use <bits/huge_val.h> directly; include <math.h> instead."
26 #include <bits/wordsize.h>
28 /* IEEE positive infinity (-HUGE_VAL is negative infinity). */
32 # if __GNUC_PREREQ(2,96)
34 # define HUGE_VAL (__extension__ 0x1.0p2047)
40 ((union { unsigned __l __attribute__((__mode__(__DI__))); double __d; }) \
41 { __l: 0x7ff0000000000000ULL }).__d)
47 typedef union { unsigned char __c[8]; double __d; } __huge_val_t;
49 # define __HUGE_VAL_bytes { 0x7f, 0xf0, 0, 0, 0, 0, 0, 0 }
51 static __huge_val_t __huge_val = { __HUGE_VAL_bytes };
52 # define HUGE_VAL (__huge_val.__d)
57 /* ISO C99 extensions: (float) HUGE_VALF and (long double) HUGE_VALL. */
61 # if __GNUC_PREREQ(2,96)
63 # define HUGE_VALF (__extension__ 0x1.0p255f)
65 # define HUGE_VALL HUGE_VAL
67 /* Sparc64 uses IEEE 754 128bit long double */
68 # define HUGE_VALL (__extension__ 0x1.0p32767L)
77 ((union { unsigned __l __attribute__((__mode__(__SI__))); float __d; }) \
78 { __l: 0x7f800000UL }).__d)
82 typedef union { unsigned char __c[4]; float __f; } __huge_valf_t;
84 # define __HUGE_VALF_bytes { 0x7f, 0x80, 0, 0 }
86 static __huge_valf_t __huge_valf = { __HUGE_VALF_bytes };
87 # define HUGE_VALF (__huge_valf.__f)
93 /* Sparc32 has IEEE 754 64bit long double */
94 # define HUGE_VALL HUGE_VAL
98 /* Sparc64 uses IEEE 754 128bit long double */
104 ((union { struct { unsigned long __h, __l; } __i; long double __d; }) \
105 { __i: { __h: 0x7fff000000000000UL, __l: 0 } }).__d)
109 typedef union { unsigned char __c[16]; long double __d; } __huge_vall_t;
111 # define __HUGE_VALL_bytes { 0x7f, 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
113 static __huge_vall_t __huge_vall = { __HUGE_VALL_bytes };
114 # define HUGE_VALL (__huge_vall.__d)
120 # endif /* GCC 2.95. */
122 #endif /* __USE_ISOC99. */