Elliott Hughes | 02c78a3 | 2014-04-11 17:02:20 -0700 | [diff] [blame] | 1 | /* $OpenBSD: ieee.h,v 1.4 2011/11/08 17:06:51 deraadt Exp $ */ |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 2 | /* $NetBSD: ieee.h,v 1.2 2001/02/21 17:43:50 bjh21 Exp $ */ |
| 3 | |
| 4 | /* |
| 5 | * Copyright (c) 1992, 1993 |
| 6 | * The Regents of the University of California. All rights reserved. |
| 7 | * |
| 8 | * This software was developed by the Computer Systems Engineering group |
| 9 | * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and |
| 10 | * contributed to Berkeley. |
| 11 | * |
| 12 | * All advertising materials mentioning features or use of this software |
| 13 | * must display the following acknowledgement: |
| 14 | * This product includes software developed by the University of |
| 15 | * California, Lawrence Berkeley Laboratory. |
| 16 | * |
| 17 | * Redistribution and use in source and binary forms, with or without |
| 18 | * modification, are permitted provided that the following conditions |
| 19 | * are met: |
| 20 | * 1. Redistributions of source code must retain the above copyright |
| 21 | * notice, this list of conditions and the following disclaimer. |
| 22 | * 2. Redistributions in binary form must reproduce the above copyright |
| 23 | * notice, this list of conditions and the following disclaimer in the |
| 24 | * documentation and/or other materials provided with the distribution. |
| 25 | * 3. All advertising materials mentioning features or use of this software |
| 26 | * must display the following acknowledgement: |
| 27 | * This product includes software developed by the University of |
| 28 | * California, Berkeley and its contributors. |
| 29 | * 4. Neither the name of the University nor the names of its contributors |
| 30 | * may be used to endorse or promote products derived from this software |
| 31 | * without specific prior written permission. |
| 32 | * |
| 33 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
| 34 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 35 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 36 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
| 37 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 38 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 39 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 40 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 41 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 42 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 43 | * SUCH DAMAGE. |
| 44 | * |
| 45 | * @(#)ieee.h 8.1 (Berkeley) 6/11/93 |
| 46 | */ |
| 47 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 48 | #define SNG_EXPBITS 8 |
| 49 | #define SNG_FRACBITS 23 |
| 50 | |
| 51 | #define DBL_EXPBITS 11 |
Elliott Hughes | 02c78a3 | 2014-04-11 17:02:20 -0700 | [diff] [blame] | 52 | #define DBL_FRACHBITS 20 |
| 53 | #define DBL_FRACLBITS 32 |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 54 | #define DBL_FRACBITS 52 |
| 55 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 56 | struct ieee_single { |
| 57 | u_int sng_frac:23; |
Elliott Hughes | 02c78a3 | 2014-04-11 17:02:20 -0700 | [diff] [blame] | 58 | u_int sng_exp:8; |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 59 | u_int sng_sign:1; |
| 60 | }; |
| 61 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 62 | struct ieee_double { |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 63 | u_int dbl_fracl; |
| 64 | u_int dbl_frach:20; |
| 65 | u_int dbl_exp:11; |
| 66 | u_int dbl_sign:1; |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 67 | }; |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 68 | |
| 69 | /* |
| 70 | * Floats whose exponent is in [1..INFNAN) (of whatever type) are |
| 71 | * `normal'. Floats whose exponent is INFNAN are either Inf or NaN. |
| 72 | * Floats whose exponent is zero are either zero (iff all fraction |
| 73 | * bits are zero) or subnormal values. |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 74 | */ |
| 75 | #define SNG_EXP_INFNAN 255 |
| 76 | #define DBL_EXP_INFNAN 2047 |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 77 | |
| 78 | /* |
| 79 | * Exponent biases. |
| 80 | */ |
| 81 | #define SNG_EXP_BIAS 127 |
| 82 | #define DBL_EXP_BIAS 1023 |