155121Storek /* 255121Storek * Copyright (c) 1992 The Regents of the University of California. 355121Storek * All rights reserved. 455121Storek * 555121Storek * This software was developed by the Computer Systems Engineering group 655121Storek * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and 755121Storek * contributed to Berkeley. 855121Storek * 9*55501Sbostic * All advertising materials mentioning features or use of this software 10*55501Sbostic * must display the following acknowledgement: 11*55501Sbostic * This product includes software developed by the University of 12*55501Sbostic * California, Lawrence Berkeley Laboratories. 13*55501Sbostic * 1455121Storek * %sccs.include.redist.c% 1555121Storek * 16*55501Sbostic * @(#)ieee.h 7.2 (Berkeley) 07/21/92 1755121Storek * 1855121Storek * from: $Header: ieee.h,v 1.6 92/06/19 23:04:29 torek Exp $ 1955121Storek */ 2055121Storek 2155121Storek /* 2255121Storek * ieee.h defines the machine-dependent layout of the machine's IEEE 2355121Storek * floating point. It does *not* define (yet?) any of the rounding 2455121Storek * mode bits, exceptions, and so forth. 2555121Storek */ 2655121Storek 2755121Storek /* 2855121Storek * Define the number of bits in each fraction and exponent. 2955121Storek * 3055121Storek * k k+1 3155121Storek * Note that 1.0 x 2 == 0.1 x 2 and that denorms are represented 3255121Storek * 3355121Storek * (-exp_bias+1) 3455121Storek * as fractions that look like 0.fffff x 2 . This means that 3555121Storek * 3655121Storek * -126 3755121Storek * the number 0.10000 x 2 , for instance, is the same as the normalized 3855121Storek * 3955121Storek * -127 -128 4055121Storek * float 1.0 x 2 . Thus, to represent 2 , we need one leading zero 4155121Storek * 4255121Storek * -129 4355121Storek * in the fraction; to represent 2 , we need two, and so on. This 4455121Storek * 4555121Storek * (-exp_bias-fracbits+1) 4655121Storek * implies that the smallest denormalized number is 2 4755121Storek * 4855121Storek * for whichever format we are talking about: for single precision, for 4955121Storek * 5055121Storek * -126 -149 5155121Storek * instance, we get .00000000000000000000001 x 2 , or 1.0 x 2 , and 5255121Storek * 5355121Storek * -149 == -127 - 23 + 1. 5455121Storek */ 5555121Storek #define SNG_EXPBITS 8 5655121Storek #define SNG_FRACBITS 23 5755121Storek 5855121Storek #define DBL_EXPBITS 11 5955121Storek #define DBL_FRACBITS 52 6055121Storek 6155121Storek #ifdef notyet 6255121Storek #define E80_EXPBITS 15 6355121Storek #define E80_FRACBITS 64 6455121Storek #endif 6555121Storek 6655121Storek #define EXT_EXPBITS 15 6755121Storek #define EXT_FRACBITS 112 6855121Storek 6955121Storek struct ieee_single { 7055121Storek u_int sng_sign:1; 7155121Storek u_int sng_exp:8; 7255121Storek u_int sng_frac:23; 7355121Storek }; 7455121Storek 7555121Storek struct ieee_double { 7655121Storek u_int dbl_sign:1; 7755121Storek u_int dbl_exp:11; 7855121Storek u_int dbl_frach:20; 7955121Storek u_int dbl_fracl; 8055121Storek }; 8155121Storek 8255121Storek struct ieee_ext { 8355121Storek u_int ext_sign:1; 8455121Storek u_int ext_exp:15; 8555121Storek u_int ext_frach:16; 8655121Storek u_int ext_frachm; 8755121Storek u_int ext_fraclm; 8855121Storek u_int ext_fracl; 8955121Storek }; 9055121Storek 9155121Storek /* 9255121Storek * Floats whose exponent is in [1..INFNAN) (of whatever type) are 9355121Storek * `normal'. Floats whose exponent is INFNAN are either Inf or NaN. 9455121Storek * Floats whose exponent is zero are either zero (iff all fraction 9555121Storek * bits are zero) or subnormal values. 9655121Storek * 9755121Storek * A NaN is a `signalling NaN' if its QUIETNAN bit is clear in its 9855121Storek * high fraction; if the bit is set, it is a `quiet NaN'. 9955121Storek */ 10055121Storek #define SNG_EXP_INFNAN 255 10155121Storek #define DBL_EXP_INFNAN 2047 10255121Storek #define EXT_EXP_INFNAN 32767 10355121Storek 10455121Storek #if 0 10555121Storek #define SNG_QUIETNAN (1 << 22) 10655121Storek #define DBL_QUIETNAN (1 << 19) 10755121Storek #define EXT_QUIETNAN (1 << 15) 10855121Storek #endif 10955121Storek 11055121Storek /* 11155121Storek * Exponent biases. 11255121Storek */ 11355121Storek #define SNG_EXP_BIAS 127 11455121Storek #define DBL_EXP_BIAS 1023 11555121Storek #define EXT_EXP_BIAS 16383 116