1234285Sdim/*-
2234285Sdim * Copyright (c) 1992, 1993
3234285Sdim *	The Regents of the University of California.  All rights reserved.
4234285Sdim *
5234285Sdim * This software was developed by the Computer Systems Engineering group
6234285Sdim * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
7234285Sdim * contributed to Berkeley.
8234285Sdim *
9234285Sdim * All advertising materials mentioning features or use of this software
10234285Sdim * must display the following acknowledgement:
11234285Sdim *	This product includes software developed by the University of
12234285Sdim *	California, Lawrence Berkeley Laboratory.
13234285Sdim *
14249423Sdim * Redistribution and use in source and binary forms, with or without
15234285Sdim * modification, are permitted provided that the following conditions
16234285Sdim * are met:
17234285Sdim * 1. Redistributions of source code must retain the above copyright
18234285Sdim *    notice, this list of conditions and the following disclaimer.
19234285Sdim * 2. Redistributions in binary form must reproduce the above copyright
20234285Sdim *    notice, this list of conditions and the following disclaimer in the
21249423Sdim *    documentation and/or other materials provided with the distribution.
22234285Sdim * 4. Neither the name of the University nor the names of its contributors
23234285Sdim *    may be used to endorse or promote products derived from this software
24249423Sdim *    without specific prior written permission.
25234285Sdim *
26234285Sdim * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27234285Sdim * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28249423Sdim * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29249423Sdim * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30249423Sdim * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31234285Sdim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32249423Sdim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33234285Sdim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34234285Sdim * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35234285Sdim * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36234285Sdim * SUCH DAMAGE.
37234285Sdim *
38234285Sdim *	@(#)ieee.h	8.1 (Berkeley) 6/11/93
39234285Sdim *	from: NetBSD: ieee.h,v 1.1.1.1 1998/06/20 04:58:51 eeh Exp
40234285Sdim * $FreeBSD$
41234285Sdim */
42234285Sdim
43234285Sdim#ifndef _MACHINE_IEEE_H_
44234285Sdim#define	_MACHINE_IEEE_H_
45234285Sdim
46234285Sdim/*
47234285Sdim * ieee.h defines the machine-dependent layout of the machine's IEEE
48234285Sdim * floating point.  It does *not* define (yet?) any of the rounding
49234285Sdim * mode bits, exceptions, and so forth.
50234285Sdim */
51234285Sdim
52234285Sdim/*
53234285Sdim * Define the number of bits in each fraction and exponent.
54234285Sdim *
55234285Sdim *		     k	         k+1
56234285Sdim * Note that  1.0 x 2  == 0.1 x 2      and that denorms are represented
57234285Sdim *
58234285Sdim *					  (-exp_bias+1)
59234285Sdim * as fractions that look like 0.fffff x 2             .  This means that
60234285Sdim *
61234285Sdim *			 -126
62234285Sdim * the number 0.10000 x 2    , for instance, is the same as the normalized
63234285Sdim *
64234285Sdim *		-127			   -128
65234285Sdim * float 1.0 x 2    .  Thus, to represent 2    , we need one leading zero
66234285Sdim *
67234285Sdim *				  -129
68234285Sdim * in the fraction; to represent 2    , we need two, and so on.  This
69234285Sdim *
70234285Sdim *						     (-exp_bias-fracbits+1)
71234285Sdim * implies that the smallest denormalized number is 2
72234285Sdim *
73234285Sdim * for whichever format we are talking about: for single precision, for
74234285Sdim *
75234285Sdim *						-126		-149
76234285Sdim * instance, we get .00000000000000000000001 x 2    , or 1.0 x 2    , and
77234285Sdim *
78234285Sdim * -149 == -127 - 23 + 1.
79234285Sdim */
80234285Sdim#define	SNG_EXPBITS	8
81234285Sdim#define	SNG_FRACBITS	23
82234285Sdim
83234285Sdim#define	DBL_EXPBITS	11
84234285Sdim#define	DBL_FRACBITS	52
85234285Sdim
86234285Sdim#ifdef notyet
87234285Sdim#define	E80_EXPBITS	15
88234285Sdim#define	E80_FRACBITS	64
89234285Sdim#endif
90234285Sdim
91234285Sdim#define	EXT_EXPBITS	15
92234285Sdim#define	EXT_FRACBITS	112
93234285Sdim
94234285Sdimstruct ieee_single {
95234285Sdim	u_int	sng_sign:1;
96234285Sdim	u_int	sng_exp:8;
97234285Sdim	u_int	sng_frac:23;
98234285Sdim};
99234285Sdim
100234285Sdimstruct ieee_double {
101234285Sdim	u_int	dbl_sign:1;
102234285Sdim	u_int	dbl_exp:11;
103234285Sdim	u_int	dbl_frach:20;
104234285Sdim	u_int	dbl_fracl;
105234285Sdim};
106234285Sdim
107234285Sdimstruct ieee_ext {
108234285Sdim	u_int	ext_sign:1;
109234285Sdim	u_int	ext_exp:15;
110234285Sdim	u_int	ext_frach:16;
111234285Sdim	u_int	ext_frachm;
112234285Sdim	u_int	ext_fraclm;
113234285Sdim	u_int	ext_fracl;
114234285Sdim};
115234285Sdim
116234285Sdim/*
117234285Sdim * Floats whose exponent is in [1..INFNAN) (of whatever type) are
118234285Sdim * `normal'.  Floats whose exponent is INFNAN are either Inf or NaN.
119234285Sdim * Floats whose exponent is zero are either zero (iff all fraction
120234285Sdim * bits are zero) or subnormal values.
121234285Sdim *
122234285Sdim * A NaN is a `signalling NaN' if its QUIETNAN bit is clear in its
123234285Sdim * high fraction; if the bit is set, it is a `quiet NaN'.
124234285Sdim */
125234285Sdim#define	SNG_EXP_INFNAN	255
126234285Sdim#define	DBL_EXP_INFNAN	2047
127234285Sdim#define	EXT_EXP_INFNAN	32767
128234285Sdim
129234285Sdim#if 0
130234285Sdim#define	SNG_QUIETNAN	(1 << 22)
131234285Sdim#define	DBL_QUIETNAN	(1 << 19)
132234285Sdim#define	EXT_QUIETNAN	(1 << 15)
133234285Sdim#endif
134234285Sdim
135234285Sdim/*
136234285Sdim * Exponent biases.
137234285Sdim */
138234285Sdim#define	SNG_EXP_BIAS	127
139234285Sdim#define	DBL_EXP_BIAS	1023
140234285Sdim#define	EXT_EXP_BIAS	16383
141234285Sdim
142234285Sdim#endif
143234285Sdim