xref: /original-bsd/sys/sparc/include/ieee.h (revision b4971bb3)
1 /*
2  * Copyright (c) 1992 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * This software was developed by the Computer Systems Engineering group
6  * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
7  * contributed to Berkeley.
8  *
9  * All advertising materials mentioning features or use of this software
10  * must display the following acknowledgement:
11  *	This product includes software developed by the University of
12  *	California, Lawrence Berkeley Laboratory.
13  *
14  * %sccs.include.redist.c%
15  *
16  *	@(#)ieee.h	7.3 (Berkeley) 04/20/93
17  *
18  * from: $Header: ieee.h,v 1.7 92/11/26 02:04:37 torek Exp $
19  */
20 
21 /*
22  * ieee.h defines the machine-dependent layout of the machine's IEEE
23  * floating point.  It does *not* define (yet?) any of the rounding
24  * mode bits, exceptions, and so forth.
25  */
26 
27 /*
28  * Define the number of bits in each fraction and exponent.
29  *
30  *		     k	         k+1
31  * Note that  1.0 x 2  == 0.1 x 2      and that denorms are represented
32  *
33  *					  (-exp_bias+1)
34  * as fractions that look like 0.fffff x 2             .  This means that
35  *
36  *			 -126
37  * the number 0.10000 x 2    , for instance, is the same as the normalized
38  *
39  *		-127			   -128
40  * float 1.0 x 2    .  Thus, to represent 2    , we need one leading zero
41  *
42  *				  -129
43  * in the fraction; to represent 2    , we need two, and so on.  This
44  *
45  *						     (-exp_bias-fracbits+1)
46  * implies that the smallest denormalized number is 2
47  *
48  * for whichever format we are talking about: for single precision, for
49  *
50  *						-126		-149
51  * instance, we get .00000000000000000000001 x 2    , or 1.0 x 2    , and
52  *
53  * -149 == -127 - 23 + 1.
54  */
55 #define	SNG_EXPBITS	8
56 #define	SNG_FRACBITS	23
57 
58 #define	DBL_EXPBITS	11
59 #define	DBL_FRACBITS	52
60 
61 #ifdef notyet
62 #define	E80_EXPBITS	15
63 #define	E80_FRACBITS	64
64 #endif
65 
66 #define	EXT_EXPBITS	15
67 #define	EXT_FRACBITS	112
68 
69 struct ieee_single {
70 	u_int	sng_sign:1;
71 	u_int	sng_exp:8;
72 	u_int	sng_frac:23;
73 };
74 
75 struct ieee_double {
76 	u_int	dbl_sign:1;
77 	u_int	dbl_exp:11;
78 	u_int	dbl_frach:20;
79 	u_int	dbl_fracl;
80 };
81 
82 struct ieee_ext {
83 	u_int	ext_sign:1;
84 	u_int	ext_exp:15;
85 	u_int	ext_frach:16;
86 	u_int	ext_frachm;
87 	u_int	ext_fraclm;
88 	u_int	ext_fracl;
89 };
90 
91 /*
92  * Floats whose exponent is in [1..INFNAN) (of whatever type) are
93  * `normal'.  Floats whose exponent is INFNAN are either Inf or NaN.
94  * Floats whose exponent is zero are either zero (iff all fraction
95  * bits are zero) or subnormal values.
96  *
97  * A NaN is a `signalling NaN' if its QUIETNAN bit is clear in its
98  * high fraction; if the bit is set, it is a `quiet NaN'.
99  */
100 #define	SNG_EXP_INFNAN	255
101 #define	DBL_EXP_INFNAN	2047
102 #define	EXT_EXP_INFNAN	32767
103 
104 #if 0
105 #define	SNG_QUIETNAN	(1 << 22)
106 #define	DBL_QUIETNAN	(1 << 19)
107 #define	EXT_QUIETNAN	(1 << 15)
108 #endif
109 
110 /*
111  * Exponent biases.
112  */
113 #define	SNG_EXP_BIAS	127
114 #define	DBL_EXP_BIAS	1023
115 #define	EXT_EXP_BIAS	16383
116