1139825Simp/*-
2109480Sgrehan * Copyright (c) 1992, 1993
3109480Sgrehan *	The Regents of the University of California.  All rights reserved.
4109480Sgrehan *
5109480Sgrehan * This software was developed by the Computer Systems Engineering group
6109480Sgrehan * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
7109480Sgrehan * contributed to Berkeley.
8109480Sgrehan *
9109480Sgrehan * All advertising materials mentioning features or use of this software
10109480Sgrehan * must display the following acknowledgement:
11109480Sgrehan *	This product includes software developed by the University of
12109480Sgrehan *	California, Lawrence Berkeley Laboratory.
13109480Sgrehan *
14109480Sgrehan * Redistribution and use in source and binary forms, with or without
15109480Sgrehan * modification, are permitted provided that the following conditions
16109480Sgrehan * are met:
17109480Sgrehan * 1. Redistributions of source code must retain the above copyright
18109480Sgrehan *    notice, this list of conditions and the following disclaimer.
19109480Sgrehan * 2. Redistributions in binary form must reproduce the above copyright
20109480Sgrehan *    notice, this list of conditions and the following disclaimer in the
21109480Sgrehan *    documentation and/or other materials provided with the distribution.
22109480Sgrehan * 4. Neither the name of the University nor the names of its contributors
23109480Sgrehan *    may be used to endorse or promote products derived from this software
24109480Sgrehan *    without specific prior written permission.
25109480Sgrehan *
26109480Sgrehan * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27109480Sgrehan * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28109480Sgrehan * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29109480Sgrehan * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30109480Sgrehan * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31109480Sgrehan * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32109480Sgrehan * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33109480Sgrehan * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34109480Sgrehan * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35109480Sgrehan * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36109480Sgrehan * SUCH DAMAGE.
37109480Sgrehan *
38109480Sgrehan *	@(#)ieee.h	8.1 (Berkeley) 6/11/93
39109480Sgrehan *	from: NetBSD: ieee.h,v 1.1.1.1 1998/06/20 04:58:51 eeh Exp
40109480Sgrehan * $FreeBSD: releng/10.3/sys/powerpc/include/ieee.h 139825 2005-01-07 02:29:27Z imp $
41109480Sgrehan */
42109480Sgrehan
43109480Sgrehan#ifndef _MACHINE_IEEE_H_
44109480Sgrehan#define	_MACHINE_IEEE_H_
45109480Sgrehan
46109480Sgrehan/*
47109480Sgrehan * ieee.h defines the machine-dependent layout of the machine's IEEE
48109480Sgrehan * floating point.  It does *not* define (yet?) any of the rounding
49109480Sgrehan * mode bits, exceptions, and so forth.
50109480Sgrehan */
51109480Sgrehan
52109480Sgrehan/*
53109480Sgrehan * Define the number of bits in each fraction and exponent.
54109480Sgrehan *
55109480Sgrehan *		     k	         k+1
56109480Sgrehan * Note that  1.0 x 2  == 0.1 x 2      and that denorms are represented
57109480Sgrehan *
58109480Sgrehan *					  (-exp_bias+1)
59109480Sgrehan * as fractions that look like 0.fffff x 2             .  This means that
60109480Sgrehan *
61109480Sgrehan *			 -126
62109480Sgrehan * the number 0.10000 x 2    , for instance, is the same as the normalized
63109480Sgrehan *
64109480Sgrehan *		-127			   -128
65109480Sgrehan * float 1.0 x 2    .  Thus, to represent 2    , we need one leading zero
66109480Sgrehan *
67109480Sgrehan *				  -129
68109480Sgrehan * in the fraction; to represent 2    , we need two, and so on.  This
69109480Sgrehan *
70109480Sgrehan *						     (-exp_bias-fracbits+1)
71109480Sgrehan * implies that the smallest denormalized number is 2
72109480Sgrehan *
73109480Sgrehan * for whichever format we are talking about: for single precision, for
74109480Sgrehan *
75109480Sgrehan *						-126		-149
76109480Sgrehan * instance, we get .00000000000000000000001 x 2    , or 1.0 x 2    , and
77109480Sgrehan *
78109480Sgrehan * -149 == -127 - 23 + 1.
79109480Sgrehan */
80109480Sgrehan#define	SNG_EXPBITS	8
81109480Sgrehan#define	SNG_FRACBITS	23
82109480Sgrehan
83109480Sgrehan#define	DBL_EXPBITS	11
84109480Sgrehan#define	DBL_FRACBITS	52
85109480Sgrehan
86109480Sgrehan#ifdef notyet
87109480Sgrehan#define	E80_EXPBITS	15
88109480Sgrehan#define	E80_FRACBITS	64
89109480Sgrehan#endif
90109480Sgrehan
91109480Sgrehan#define	EXT_EXPBITS	15
92109480Sgrehan#define	EXT_FRACBITS	112
93109480Sgrehan
94109480Sgrehanstruct ieee_single {
95109480Sgrehan	u_int	sng_sign:1;
96109480Sgrehan	u_int	sng_exp:8;
97109480Sgrehan	u_int	sng_frac:23;
98109480Sgrehan};
99109480Sgrehan
100109480Sgrehanstruct ieee_double {
101109480Sgrehan	u_int	dbl_sign:1;
102109480Sgrehan	u_int	dbl_exp:11;
103109480Sgrehan	u_int	dbl_frach:20;
104109480Sgrehan	u_int	dbl_fracl;
105109480Sgrehan};
106109480Sgrehan
107109480Sgrehanstruct ieee_ext {
108109480Sgrehan	u_int	ext_sign:1;
109109480Sgrehan	u_int	ext_exp:15;
110109480Sgrehan	u_int	ext_frach:16;
111109480Sgrehan	u_int	ext_frachm;
112109480Sgrehan	u_int	ext_fraclm;
113109480Sgrehan	u_int	ext_fracl;
114109480Sgrehan};
115109480Sgrehan
116109480Sgrehan/*
117109480Sgrehan * Floats whose exponent is in [1..INFNAN) (of whatever type) are
118109480Sgrehan * `normal'.  Floats whose exponent is INFNAN are either Inf or NaN.
119109480Sgrehan * Floats whose exponent is zero are either zero (iff all fraction
120109480Sgrehan * bits are zero) or subnormal values.
121109480Sgrehan *
122109480Sgrehan * A NaN is a `signalling NaN' if its QUIETNAN bit is clear in its
123109480Sgrehan * high fraction; if the bit is set, it is a `quiet NaN'.
124109480Sgrehan */
125109480Sgrehan#define	SNG_EXP_INFNAN	255
126109480Sgrehan#define	DBL_EXP_INFNAN	2047
127109480Sgrehan#define	EXT_EXP_INFNAN	32767
128109480Sgrehan
129109480Sgrehan#if 0
130109480Sgrehan#define	SNG_QUIETNAN	(1 << 22)
131109480Sgrehan#define	DBL_QUIETNAN	(1 << 19)
132109480Sgrehan#define	EXT_QUIETNAN	(1 << 15)
133109480Sgrehan#endif
134109480Sgrehan
135109480Sgrehan/*
136109480Sgrehan * Exponent biases.
137109480Sgrehan */
138109480Sgrehan#define	SNG_EXP_BIAS	127
139109480Sgrehan#define	DBL_EXP_BIAS	1023
140109480Sgrehan#define	EXT_EXP_BIAS	16383
141109480Sgrehan
142109480Sgrehan#endif
143