Import R6RS bytevectors and I/O ports from Guile-R6RS-Libs 0.2.
[bpt/guile.git] / libguile / ieee-754.h
1 /* Copyright (C) 1992, 1995, 1996, 1999 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, write to the Free
16 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17 02111-1307 USA. */
18
19 #ifndef SCM_IEEE_754_H
20 #define SCM_IEEE_754_H 1
21
22 /* Based on glibc's <ieee754.h> and modified by Ludovic Courtès to include
23 all possible IEEE-754 double-precision representations. */
24
25 \f
26 /* IEEE 754 simple-precision format (32-bit). */
27
28 union scm_ieee754_float
29 {
30 float f;
31
32 struct
33 {
34 unsigned int negative:1;
35 unsigned int exponent:8;
36 unsigned int mantissa:23;
37 } big_endian;
38
39 struct
40 {
41 unsigned int mantissa:23;
42 unsigned int exponent:8;
43 unsigned int negative:1;
44 } little_endian;
45 };
46
47
48 \f
49 /* IEEE 754 double-precision format (64-bit). */
50
51 union scm_ieee754_double
52 {
53 double d;
54
55 struct
56 {
57 /* Big endian. */
58
59 unsigned int negative:1;
60 unsigned int exponent:11;
61 /* Together these comprise the mantissa. */
62 unsigned int mantissa0:20;
63 unsigned int mantissa1:32;
64 } big_endian;
65
66 struct
67 {
68 /* Both byte order and word order are little endian. */
69
70 /* Together these comprise the mantissa. */
71 unsigned int mantissa1:32;
72 unsigned int mantissa0:20;
73 unsigned int exponent:11;
74 unsigned int negative:1;
75 } little_little_endian;
76
77 struct
78 {
79 /* Byte order is little endian but word order is big endian. Not
80 sure this is very wide spread. */
81 unsigned int mantissa0:20;
82 unsigned int exponent:11;
83 unsigned int negative:1;
84 unsigned int mantissa1:32;
85 } little_big_endian;
86
87 };
88
89
90 #endif /* SCM_IEEE_754_H */