xref: /illumos-gate/usr/src/head/float.h (revision b4203d75)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
227c478bd9Sstevel@tonic-gate /*	Copyright (c) 1988 AT&T	*/
23*b4203d75SMarcel Telka /*	  All Rights Reserved	*/
247c478bd9Sstevel@tonic-gate 
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate /*
27ba3594baSGarrett D'Amore  * Copyright 2014 Garrett D'Amore <garrett@damore.org>
28ba3594baSGarrett D'Amore  *
297c478bd9Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
307c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
317c478bd9Sstevel@tonic-gate  */
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate #ifndef _FLOAT_H
347c478bd9Sstevel@tonic-gate #define	_FLOAT_H
357c478bd9Sstevel@tonic-gate 
367c478bd9Sstevel@tonic-gate #include <sys/feature_tests.h>
377c478bd9Sstevel@tonic-gate 
387c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
397c478bd9Sstevel@tonic-gate extern "C" {
407c478bd9Sstevel@tonic-gate #endif
417c478bd9Sstevel@tonic-gate 
427c478bd9Sstevel@tonic-gate #if defined(__sparc)
437c478bd9Sstevel@tonic-gate 
447c478bd9Sstevel@tonic-gate extern int __flt_rounds(void);
457c478bd9Sstevel@tonic-gate #define	FLT_ROUNDS	__flt_rounds()
467c478bd9Sstevel@tonic-gate 
477c478bd9Sstevel@tonic-gate #else /* defined(__sparc) */
487c478bd9Sstevel@tonic-gate 
497c478bd9Sstevel@tonic-gate extern int __fltrounds(void);
50ba3594baSGarrett D'Amore 
517c478bd9Sstevel@tonic-gate #if defined(__amd64)
527c478bd9Sstevel@tonic-gate #define	FLT_ROUNDS	__fltrounds()
537c478bd9Sstevel@tonic-gate #else	/* defined(__amd64) */
547c478bd9Sstevel@tonic-gate extern int __flt_rounds;
557c478bd9Sstevel@tonic-gate #define	FLT_ROUNDS	__flt_rounds
567c478bd9Sstevel@tonic-gate #endif	/* defined(__amd64) */
577c478bd9Sstevel@tonic-gate #endif /* defined(__sparc) */
587c478bd9Sstevel@tonic-gate 
597c478bd9Sstevel@tonic-gate /* Introduced in ISO/IEC 9899:1999 standard */
607c478bd9Sstevel@tonic-gate #if defined(__EXTENSIONS__) || defined(_STDC_C99) || \
617c478bd9Sstevel@tonic-gate 	(!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX))
627c478bd9Sstevel@tonic-gate #if defined(__FLT_EVAL_METHOD__)
637c478bd9Sstevel@tonic-gate #define	FLT_EVAL_METHOD __FLT_EVAL_METHOD__
647c478bd9Sstevel@tonic-gate #else
657c478bd9Sstevel@tonic-gate #define	FLT_EVAL_METHOD	-1
667c478bd9Sstevel@tonic-gate #endif /* defined(__FLT_EVAL_METHOD__) */
677c478bd9Sstevel@tonic-gate #endif /* defined(__EXTENSIONS__) || defined(_STDC_C99)... */
687c478bd9Sstevel@tonic-gate 
697c478bd9Sstevel@tonic-gate #define	FLT_RADIX	2
707c478bd9Sstevel@tonic-gate #define	FLT_MANT_DIG	24
717c478bd9Sstevel@tonic-gate #define	FLT_EPSILON	1.1920928955078125000000E-07F
727c478bd9Sstevel@tonic-gate #define	FLT_DIG		6
737c478bd9Sstevel@tonic-gate #define	FLT_MIN_EXP	(-125)
747c478bd9Sstevel@tonic-gate #define	FLT_MIN		1.1754943508222875079688E-38F
757c478bd9Sstevel@tonic-gate #define	FLT_MIN_10_EXP	(-37)
767c478bd9Sstevel@tonic-gate #define	FLT_MAX_EXP	(+128)
777c478bd9Sstevel@tonic-gate #define	FLT_MAX		3.4028234663852885981170E+38F
787c478bd9Sstevel@tonic-gate #define	FLT_MAX_10_EXP	(+38)
797c478bd9Sstevel@tonic-gate 
807c478bd9Sstevel@tonic-gate #define	DBL_MANT_DIG	53
817c478bd9Sstevel@tonic-gate #define	DBL_EPSILON	2.2204460492503130808473E-16
827c478bd9Sstevel@tonic-gate #define	DBL_DIG		15
837c478bd9Sstevel@tonic-gate #define	DBL_MIN_EXP	(-1021)
847c478bd9Sstevel@tonic-gate #define	DBL_MIN		2.2250738585072013830903E-308
857c478bd9Sstevel@tonic-gate #define	DBL_MIN_10_EXP	(-307)
867c478bd9Sstevel@tonic-gate #define	DBL_MAX_EXP	(+1024)
877c478bd9Sstevel@tonic-gate #define	DBL_MAX		1.7976931348623157081452E+308
887c478bd9Sstevel@tonic-gate #define	DBL_MAX_10_EXP	(+308)
897c478bd9Sstevel@tonic-gate 
907c478bd9Sstevel@tonic-gate /* Introduced in ISO/IEC 9899:1999 standard */
917c478bd9Sstevel@tonic-gate #if defined(__EXTENSIONS__) || defined(_STDC_C99) || \
927c478bd9Sstevel@tonic-gate 	(!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX))
937c478bd9Sstevel@tonic-gate #if defined(__sparc)
947c478bd9Sstevel@tonic-gate #define	DECIMAL_DIG	36
957c478bd9Sstevel@tonic-gate #elif defined(__i386) || defined(__amd64)
967c478bd9Sstevel@tonic-gate #define	DECIMAL_DIG	21
977c478bd9Sstevel@tonic-gate #endif
987c478bd9Sstevel@tonic-gate #endif /* defined(__EXTENSIONS__) || defined(_STDC_C99)... */
997c478bd9Sstevel@tonic-gate 
1007c478bd9Sstevel@tonic-gate 
1017c478bd9Sstevel@tonic-gate #if defined(__i386) || defined(__amd64)
1027c478bd9Sstevel@tonic-gate 
1037c478bd9Sstevel@tonic-gate /* Follows IEEE standards for 80-bit floating point */
1047c478bd9Sstevel@tonic-gate #define	LDBL_MANT_DIG	64
1057c478bd9Sstevel@tonic-gate #define	LDBL_EPSILON	1.0842021724855044340075E-19L
1067c478bd9Sstevel@tonic-gate #define	LDBL_DIG	18
1077c478bd9Sstevel@tonic-gate #define	LDBL_MIN_EXP	(-16381)
1087c478bd9Sstevel@tonic-gate #define	LDBL_MIN	3.3621031431120935062627E-4932L
1097c478bd9Sstevel@tonic-gate #define	LDBL_MIN_10_EXP	(-4931)
1107c478bd9Sstevel@tonic-gate #define	LDBL_MAX_EXP	(+16384)
1117c478bd9Sstevel@tonic-gate #define	LDBL_MAX	1.1897314953572317650213E+4932L
1127c478bd9Sstevel@tonic-gate #define	LDBL_MAX_10_EXP	(+4932)
1137c478bd9Sstevel@tonic-gate 
1147c478bd9Sstevel@tonic-gate #elif defined(__sparc)
1157c478bd9Sstevel@tonic-gate 
1167c478bd9Sstevel@tonic-gate /* Follows IEEE standards for 128-bit floating point */
1177c478bd9Sstevel@tonic-gate #define	LDBL_MANT_DIG	113
1187c478bd9Sstevel@tonic-gate #define	LDBL_EPSILON	1.925929944387235853055977942584927319E-34L
1197c478bd9Sstevel@tonic-gate #define	LDBL_DIG	33
1207c478bd9Sstevel@tonic-gate #define	LDBL_MIN_EXP	(-16381)
1217c478bd9Sstevel@tonic-gate #define	LDBL_MIN	3.362103143112093506262677817321752603E-4932L
1227c478bd9Sstevel@tonic-gate #define	LDBL_MIN_10_EXP	(-4931)
1237c478bd9Sstevel@tonic-gate #define	LDBL_MAX_EXP	(+16384)
1247c478bd9Sstevel@tonic-gate #define	LDBL_MAX	1.189731495357231765085759326628007016E+4932L
1257c478bd9Sstevel@tonic-gate #define	LDBL_MAX_10_EXP	(+4932)
1267c478bd9Sstevel@tonic-gate 
1277c478bd9Sstevel@tonic-gate #else
1287c478bd9Sstevel@tonic-gate 
1297c478bd9Sstevel@tonic-gate #error "Unknown architecture!"
1307c478bd9Sstevel@tonic-gate 
1317c478bd9Sstevel@tonic-gate #endif
1327c478bd9Sstevel@tonic-gate 
1337c478bd9Sstevel@tonic-gate 
1347c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1357c478bd9Sstevel@tonic-gate }
1367c478bd9Sstevel@tonic-gate #endif
1377c478bd9Sstevel@tonic-gate 
1387c478bd9Sstevel@tonic-gate #endif	/* _FLOAT_H */
139