xref: /netbsd-src/sys/arch/x86/include/float.h (revision 8365a3465e074d741d13613af645805a729be256)
1*8365a346Srillig /*	$NetBSD: float.h,v 1.8 2024/06/15 11:44:09 rillig Exp $	*/
28375b2d9Sfvdl 
38375b2d9Sfvdl #ifndef _X86_FLOAT_H_
48375b2d9Sfvdl #define _X86_FLOAT_H_
58375b2d9Sfvdl 
689a508fbSjoerg #include <sys/featuretest.h>
789a508fbSjoerg 
8ba889294Sdholland /*
9ba889294Sdholland  * LDBL_MIN is twice the m68k LDBL_MIN, even though both are 12-byte
10ba889294Sdholland  * floats with the same base properties and both allegedly
11ba889294Sdholland  * IEEE-compliant, because both these representations materialize the
12ba889294Sdholland  * top (integer-part) bit of the mantissa. But on m68k if the exponent
13ba889294Sdholland  * is 0 and the integer bit is set, it's a regular number, whereas on
14ba889294Sdholland  * x86 it's called a pseudo-denormal and apparently treated as a
15ba889294Sdholland  * denormal, so it doesn't count as a valid value for LDBL_MIN.
16ba889294Sdholland  *
17ba889294Sdholland  * x86 citation: Intel 64 and IA-32 Architectures Software Developer's
18ba889294Sdholland  * Manual, vol. 1 (Order Number: 253665-077US, April 2022), Sec. 8.2.2
19ba889294Sdholland  * `Unsupported Double Extended-Precision Floating-Point Encodings
20ba889294Sdholland  * and Pseudo-Denormals', p. 8-14.
21ba889294Sdholland  *
22ba889294Sdholland  * m86k citation: MC68881/MC68882 Floating-Point Coprocessor User's
23ba889294Sdholland  * Manual, Second Edition (Prentice-Hall, 1989, apparently issued by
24ba889294Sdholland  * Freescale), Section 3.2 `Binary Real Data formats', pg. 3-3 bottom
25ba889294Sdholland  * in particular and pp. 3-2 to 3-5 in general.
26ba889294Sdholland  *
27ba889294Sdholland  * If anyone needs to update this comment please make sure the copy in
28*8365a346Srillig  * m68k/include/float.h also gets updated.
29ba889294Sdholland  */
30ba889294Sdholland 
318375b2d9Sfvdl #define	LDBL_MANT_DIG	64
3242269767Skleink #define LDBL_EPSILON	1.0842021724855044340E-19L
3342269767Skleink #define LDBL_DIG	18
3442269767Skleink #define LDBL_MIN_EXP	(-16381)
35f1726c27Schristos #define LDBL_MIN	3.3621031431120935063E-4932L
3642269767Skleink #define LDBL_MIN_10_EXP	(-4931)
3742269767Skleink #define LDBL_MAX_EXP	16384
3842269767Skleink #define LDBL_MAX	1.1897314953572317650E+4932L
3942269767Skleink #define LDBL_MAX_10_EXP	4932
4042269767Skleink 
41776138eaSkleink #include <sys/float_ieee754.h>
428375b2d9Sfvdl 
4342269767Skleink #if !defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) && \
4442269767Skleink     !defined(_XOPEN_SOURCE) || \
4542269767Skleink     ((__STDC_VERSION__ - 0) >= 199901L) || \
4642269767Skleink     ((_POSIX_C_SOURCE - 0) >= 200112L) || \
4742269767Skleink     ((_XOPEN_SOURCE  - 0) >= 600) || \
4842269767Skleink     defined(_ISOC99_SOURCE) || defined(_NETBSD_SOURCE)
4942269767Skleink #define	DECIMAL_DIG	21
5042269767Skleink #endif /* !defined(_ANSI_SOURCE) && ... */
5142269767Skleink 
528375b2d9Sfvdl #endif	/* _X86_FLOAT_H_ */
53