Dr Andrew Scott G7VAV

My photo
 
May 2024
Mo Tu We Th Fr Sa Su
29 30 1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31 1 2
3 4 5 6 7 8 9


ieee754.h
001: /* Copyright (C) 1992, 1995, 1996, 1999 Free Software Foundation, Inc.
002:    This file is part of the GNU C Library.
003: 
004:    The GNU C Library is free software; you can redistribute it and/or
005:    modify it under the terms of the GNU Lesser General Public
006:    License as published by the Free Software Foundation; either
007:    version 2.1 of the License, or (at your option) any later version.
008: 
009:    The GNU C Library is distributed in the hope that it will be useful,
010:    but WITHOUT ANY WARRANTY; without even the implied warranty of
011:    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
012:    Lesser General Public License for more details.
013: 
014:    You should have received a copy of the GNU Lesser General Public
015:    License along with the GNU C Library; if not, write to the Free
016:    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
017:    02111-1307 USA.  */
018: 
019: #ifndef _IEEE754_H
020: 
021: #define _IEEE754_H 1
022: #include <features.h>
023: 
024: #include <endian.h>
025: 
026: __BEGIN_DECLS
027: 
028: union ieee754_float
029:   {
030:     float f;
031: 
032:     /* This is the IEEE 754 single-precision format.  */
033:     struct
034:       {
035: #if     __BYTE_ORDER == __BIG_ENDIAN
036:         unsigned int negative:1;
037:         unsigned int exponent:8;
038:         unsigned int mantissa:23;
039: #endif                          /* Big endian.  */
040: #if     __BYTE_ORDER == __LITTLE_ENDIAN
041:         unsigned int mantissa:23;
042:         unsigned int exponent:8;
043:         unsigned int negative:1;
044: #endif                          /* Little endian.  */
045:       } ieee;
046: 
047:     /* This format makes it easier to see if a NaN is a signalling NaN.  */
048:     struct
049:       {
050: #if     __BYTE_ORDER == __BIG_ENDIAN
051:         unsigned int negative:1;
052:         unsigned int exponent:8;
053:         unsigned int quiet_nan:1;
054:         unsigned int mantissa:22;
055: #endif                          /* Big endian.  */
056: #if     __BYTE_ORDER == __LITTLE_ENDIAN
057:         unsigned int mantissa:22;
058:         unsigned int quiet_nan:1;
059:         unsigned int exponent:8;
060:         unsigned int negative:1;
061: #endif                          /* Little endian.  */
062:       } ieee_nan;
063:   };
064: 
065: #define IEEE754_FLOAT_BIAS      0x7f /* Added to exponent.  */
066: 
067: 
068: union ieee754_double
069:   {
070:     double d;
071: 
072:     /* This is the IEEE 754 double-precision format.  */
073:     struct
074:       {
075: #if     __BYTE_ORDER == __BIG_ENDIAN
076:         unsigned int negative:1;
077:         unsigned int exponent:11;
078:         /* Together these comprise the mantissa.  */
079:         unsigned int mantissa0:20;
080:         unsigned int mantissa1:32;
081: #endif                          /* Big endian.  */
082: #if     __BYTE_ORDER == __LITTLE_ENDIAN
083: # if    __FLOAT_WORD_ORDER == __BIG_ENDIAN
084:         unsigned int mantissa0:20;
085:         unsigned int exponent:11;
086:         unsigned int negative:1;
087:         unsigned int mantissa1:32;
088: # else
089:         /* Together these comprise the mantissa.  */
090:         unsigned int mantissa1:32;
091:         unsigned int mantissa0:20;
092:         unsigned int exponent:11;
093:         unsigned int negative:1;
094: # endif
095: #endif                          /* Little endian.  */
096:       } ieee;
097: 
098:     /* This format makes it easier to see if a NaN is a signalling NaN.  */
099:     struct
100:       {
101: #if     __BYTE_ORDER == __BIG_ENDIAN
102:         unsigned int negative:1;
103:         unsigned int exponent:11;
104:         unsigned int quiet_nan:1;
105:         /* Together these comprise the mantissa.  */
106:         unsigned int mantissa0:19;
107:         unsigned int mantissa1:32;
108: #else
109: # if    __FLOAT_WORD_ORDER == __BIG_ENDIAN
110:         unsigned int mantissa0:19;
111:         unsigned int quiet_nan:1;
112:         unsigned int exponent:11;
113:         unsigned int negative:1;
114:         unsigned int mantissa1:32;
115: # else
116:         /* Together these comprise the mantissa.  */
117:         unsigned int mantissa1:32;
118:         unsigned int mantissa0:19;
119:         unsigned int quiet_nan:1;
120:         unsigned int exponent:11;
121:         unsigned int negative:1;
122: # endif
123: #endif
124:       } ieee_nan;
125:   };
126: 
127: #define IEEE754_DOUBLE_BIAS     0x3ff /* Added to exponent.  */
128: 
129: 
130: union ieee854_long_double
131:   {
132:     long double d;
133: 
134:     /* This is the IEEE 854 double-extended-precision format.  */
135:     struct
136:       {
137: #if     __BYTE_ORDER == __BIG_ENDIAN
138:         unsigned int negative:1;
139:         unsigned int exponent:15;
140:         unsigned int empty:16;
141:         unsigned int mantissa0:32;
142:         unsigned int mantissa1:32;
143: #endif
144: #if     __BYTE_ORDER == __LITTLE_ENDIAN
145: # if    __FLOAT_WORD_ORDER == __BIG_ENDIAN
146:         unsigned int exponent:15;
147:         unsigned int negative:1;
148:         unsigned int empty:16;
149:         unsigned int mantissa0:32;
150:         unsigned int mantissa1:32;
151: # else
152:         unsigned int mantissa1:32;
153:         unsigned int mantissa0:32;
154:         unsigned int exponent:15;
155:         unsigned int negative:1;
156:         unsigned int empty:16;
157: # endif
158: #endif
159:       } ieee;
160: 
161:     /* This is for NaNs in the IEEE 854 double-extended-precision format.  */
162:     struct
163:       {
164: #if     __BYTE_ORDER == __BIG_ENDIAN
165:         unsigned int negative:1;
166:         unsigned int exponent:15;
167:         unsigned int empty:16;
168:         unsigned int one:1;
169:         unsigned int quiet_nan:1;
170:         unsigned int mantissa0:30;
171:         unsigned int mantissa1:32;
172: #endif
173: #if     __BYTE_ORDER == __LITTLE_ENDIAN
174: # if    __FLOAT_WORD_ORDER == __BIG_ENDIAN
175:         unsigned int exponent:15;
176:         unsigned int negative:1;
177:         unsigned int empty:16;
178:         unsigned int mantissa0:30;
179:         unsigned int quiet_nan:1;
180:         unsigned int one:1;
181:         unsigned int mantissa1:32;
182: # else
183:         unsigned int mantissa1:32;
184:         unsigned int mantissa0:30;
185:         unsigned int quiet_nan:1;
186:         unsigned int one:1;
187:         unsigned int exponent:15;
188:         unsigned int negative:1;
189:         unsigned int empty:16;
190: # endif
191: #endif
192:       } ieee_nan;
193:   };
194: 
195: #define IEEE854_LONG_DOUBLE_BIAS 0x3fff
196: 
197: __END_DECLS
198: 
199: #endif /* ieee754.h */
200: 


for client 18.188.196.223
© Andrew Scott 2006 - 2024,
All Rights Reserved
http://www.andrew-scott.uk/
Andrew Scott
http://www.andrew-scott.co.uk/