1 /* `HUGE_VAL' constant for IEEE 754 machines (where it is infinity).
2 Used by <stdlib.h> and <math.h> functions for overflow.
4 Copyright (C) 1992, 1995 Free Software Foundation, Inc.
5 This file is part of the GNU C Library.
7 The GNU C Library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public License as
9 published by the Free Software Foundation; either version 2 of the
10 License, or (at your option) any later version.
12 The GNU C Library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details.
17 You should have received a copy of the GNU Library General Public
18 License along with the GNU C Library; see the file COPYING.LIB. If
19 not, write to the Free Software Foundation, Inc., 675 Mass Ave,
20 Cambridge, MA 02139, USA. */
26 #include <sys/cdefs.h>
29 /* IEEE positive infinity (-HUGE_VAL is negative infinity). */
31 #if __BYTE_ORDER == __BIG_ENDIAN
32 #define __HUGE_VAL_bytes { 0x7f, 0xf0, 0, 0, 0, 0, 0, 0 }
34 #if __BYTE_ORDER == __LITTLE_ENDIAN
35 #define __HUGE_VAL_bytes { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f }
38 #define __huge_val_t union { unsigned char __c[8]; double __d; }
40 #define HUGE_VAL (__extension__ \
41 ((__huge_val_t) { __c: __HUGE_VAL_bytes }).__d)
43 static __huge_val_t __huge_val
= { __HUGE_VAL_bytes
};
44 #define HUGE_VAL (__huge_val.__d)
48 /* GNU extensions: (float) HUGE_VALf and (long double) HUGE_VALl. */
52 #if __BYTE_ORDER == __BIG_ENDIAN
53 #define __HUGE_VALf_bytes { 0x7f, 0x80, 0, 0 }
55 #if __BYTE_ORDER == __LITTLE_ENDIAN
56 #define __HUGE_VALf_bytes { 0, 0, 0x80, 0x7f }
59 #define __huge_valf_t union { unsigned char __c[4]; float __f; }
61 #define HUGE_VALf (__extension__ \
62 ((__huge_valf_t) { __c: __HUGE_VALf_bytes }).__f)
64 static __huge_valf_t __huge_valf
= { __HUGE_VALf_bytes
};
65 #define HUGE_VALf (__huge_valf.__f)
68 #if __BYTE_ORDER == __BIG_ENDIAN
69 #define __HUGE_VALl_bytes { 0x7f, 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
71 #if __BYTE_ORDER == __LITTLE_ENDIAN
72 #define __HUGE_VALl_bytes { 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0x7f, 0, 0 }
75 #define __huge_vall_t union { unsigned char __c[12]; long double __ld; }
77 #define HUGE_VALl (__extension__ \
78 ((__huge_vall_t) { __c: __HUGE_VALl_bytes }).__ld)
80 static __huge_vall_t __huge_vall
= { __HUGE_VALl_bytes
};
81 #define HUGE_VALl (__huge_vall.__ld)
84 #endif /* __USE_GNU. */
87 #endif /* huge_val.h */