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