annotate liboctave/lo-ieee.h @ 7814:87865ed7405f

Second set of single precision test code and fix of resulting bugs
author David Bateman <dbateman@free.fr>
date Mon, 02 Jun 2008 16:57:45 +0200
parents 82be108cc558
children 139f47cf17ab
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1967
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
1 /*
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
2
7017
a1dbe9d80eee [project @ 2007-10-12 21:27:11 by jwe]
jwe
parents: 7016
diff changeset
3 Copyright (C) 1996, 1997, 2002, 2003, 2004, 2005, 2006, 2007
a1dbe9d80eee [project @ 2007-10-12 21:27:11 by jwe]
jwe
parents: 7016
diff changeset
4 John W. Eaton
1967
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
5
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
6 This file is part of Octave.
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
7
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
8 Octave is free software; you can redistribute it and/or modify it
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
9 under the terms of the GNU General Public License as published by the
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6108
diff changeset
10 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6108
diff changeset
11 option) any later version.
1967
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
12
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
13 Octave is distributed in the hope that it will be useful, but WITHOUT
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
16 for more details.
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
17
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6108
diff changeset
19 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6108
diff changeset
20 <http://www.gnu.org/licenses/>.
1967
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
21
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
22 */
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
23
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
24 #if !defined (octave_liboctave_ieee_h)
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
25 #define octave_liboctave_ieee_h 1
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
26
4072
3cc39e3b8fa5 [project @ 2002-09-27 17:54:53 by jwe]
jwe
parents: 4025
diff changeset
27 #ifdef __cplusplus
3cc39e3b8fa5 [project @ 2002-09-27 17:54:53 by jwe]
jwe
parents: 4025
diff changeset
28 extern "C" {
3cc39e3b8fa5 [project @ 2002-09-27 17:54:53 by jwe]
jwe
parents: 4025
diff changeset
29 #endif
3cc39e3b8fa5 [project @ 2002-09-27 17:54:53 by jwe]
jwe
parents: 4025
diff changeset
30
4102
cbac6756967e [project @ 2002-10-14 20:16:44 by jwe]
jwe
parents: 4075
diff changeset
31 /* Octave's idea of infinity. */
6108
143b556ce725 [project @ 2006-10-27 01:45:54 by jwe]
jwe
parents: 5775
diff changeset
32 extern OCTAVE_API double octave_Inf;
4102
cbac6756967e [project @ 2002-10-14 20:16:44 by jwe]
jwe
parents: 4075
diff changeset
33
cbac6756967e [project @ 2002-10-14 20:16:44 by jwe]
jwe
parents: 4075
diff changeset
34 /* Octave's idea of a missing value. */
6108
143b556ce725 [project @ 2006-10-27 01:45:54 by jwe]
jwe
parents: 5775
diff changeset
35 extern OCTAVE_API double octave_NA;
4102
cbac6756967e [project @ 2002-10-14 20:16:44 by jwe]
jwe
parents: 4075
diff changeset
36
cbac6756967e [project @ 2002-10-14 20:16:44 by jwe]
jwe
parents: 4075
diff changeset
37 /* Octave's idea of not a number. */
6108
143b556ce725 [project @ 2006-10-27 01:45:54 by jwe]
jwe
parents: 5775
diff changeset
38 extern OCTAVE_API double octave_NaN;
4102
cbac6756967e [project @ 2002-10-14 20:16:44 by jwe]
jwe
parents: 4075
diff changeset
39
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
40 /* Octave's idea of infinity. */
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
41 extern OCTAVE_API float octave_Float_Inf;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
42
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
43 /* Octave's idea of a missing value. */
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
44 extern OCTAVE_API float octave_Float_NA;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
45
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
46 /* Octave's idea of not a number. */
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
47 extern OCTAVE_API float octave_Float_NaN;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
48
5775
ace8d8d26933 [project @ 2006-04-24 19:13:06 by jwe]
jwe
parents: 5389
diff changeset
49 /* FIXME -- this code assumes that a double has twice the
5388
7099eb9841b4 [project @ 2005-06-14 20:04:31 by jwe]
jwe
parents: 5307
diff changeset
50 number of bits as an int */
7099eb9841b4 [project @ 2005-06-14 20:04:31 by jwe]
jwe
parents: 5307
diff changeset
51
6108
143b556ce725 [project @ 2006-10-27 01:45:54 by jwe]
jwe
parents: 5775
diff changeset
52 extern OCTAVE_API int lo_ieee_hw;
143b556ce725 [project @ 2006-10-27 01:45:54 by jwe]
jwe
parents: 5775
diff changeset
53 extern OCTAVE_API int lo_ieee_lw;
4075
9a2102864eb0 [project @ 2002-09-27 21:37:56 by jwe]
jwe
parents: 4074
diff changeset
54
9a2102864eb0 [project @ 2002-09-27 21:37:56 by jwe]
jwe
parents: 4074
diff changeset
55 typedef union
9a2102864eb0 [project @ 2002-09-27 21:37:56 by jwe]
jwe
parents: 4074
diff changeset
56 {
9a2102864eb0 [project @ 2002-09-27 21:37:56 by jwe]
jwe
parents: 4074
diff changeset
57 double value;
9a2102864eb0 [project @ 2002-09-27 21:37:56 by jwe]
jwe
parents: 4074
diff changeset
58 unsigned int word[2];
9a2102864eb0 [project @ 2002-09-27 21:37:56 by jwe]
jwe
parents: 4074
diff changeset
59 } lo_ieee_double;
9a2102864eb0 [project @ 2002-09-27 21:37:56 by jwe]
jwe
parents: 4074
diff changeset
60
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
61 typedef union
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
62 {
7814
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
63 float value;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
64 unsigned int word;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
65 } lo_ieee_float;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
66
4075
9a2102864eb0 [project @ 2002-09-27 21:37:56 by jwe]
jwe
parents: 4074
diff changeset
67 #define LO_IEEE_NA_HW 0x7ff00000
9a2102864eb0 [project @ 2002-09-27 21:37:56 by jwe]
jwe
parents: 4074
diff changeset
68 #define LO_IEEE_NA_LW 1954
7814
87865ed7405f Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
69 #define LO_IEEE_NA_FLOAT 0x7f8207a2
4075
9a2102864eb0 [project @ 2002-09-27 21:37:56 by jwe]
jwe
parents: 4074
diff changeset
70
6108
143b556ce725 [project @ 2006-10-27 01:45:54 by jwe]
jwe
parents: 5775
diff changeset
71 extern OCTAVE_API void octave_ieee_init (void);
1967
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
72
2522
4f095783ee43 [project @ 1996-11-15 20:00:59 by jwe]
jwe
parents: 1993
diff changeset
73 #if defined (SCO)
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
74 extern int __isnan (double);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
75 extern int __isinf (double);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
76 extern int __isnanf (float);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
77 extern int __isinff (float);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
78
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
79 #define isnan(x) (sizeof (x) == sizeof (float) ? __isnanf (x) : __isnan (x))
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
80 #define isinf(x) (sizeof (x) == sizeof (float) ? __isinff (x) : __isinf (x))
4072
3cc39e3b8fa5 [project @ 2002-09-27 17:54:53 by jwe]
jwe
parents: 4025
diff changeset
81 #endif
3cc39e3b8fa5 [project @ 2002-09-27 17:54:53 by jwe]
jwe
parents: 4025
diff changeset
82
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
83 extern OCTAVE_API int __lo_ieee_isnan (double x);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
84 extern OCTAVE_API int __lo_ieee_finite (double x);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
85 extern OCTAVE_API int __lo_ieee_isinf (double x);
4072
3cc39e3b8fa5 [project @ 2002-09-27 17:54:53 by jwe]
jwe
parents: 4025
diff changeset
86
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
87 extern OCTAVE_API int __lo_ieee_is_NA (double);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
88 extern OCTAVE_API int __lo_ieee_is_NaN_or_NA (double) GCC_ATTR_DEPRECATED;
4075
9a2102864eb0 [project @ 2002-09-27 21:37:56 by jwe]
jwe
parents: 4074
diff changeset
89
6108
143b556ce725 [project @ 2006-10-27 01:45:54 by jwe]
jwe
parents: 5775
diff changeset
90 extern OCTAVE_API double lo_ieee_inf_value (void);
143b556ce725 [project @ 2006-10-27 01:45:54 by jwe]
jwe
parents: 5775
diff changeset
91 extern OCTAVE_API double lo_ieee_na_value (void);
143b556ce725 [project @ 2006-10-27 01:45:54 by jwe]
jwe
parents: 5775
diff changeset
92 extern OCTAVE_API double lo_ieee_nan_value (void);
4102
cbac6756967e [project @ 2002-10-14 20:16:44 by jwe]
jwe
parents: 4075
diff changeset
93
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
94 extern OCTAVE_API int __lo_ieee_signbit (double);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
95
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
96 extern OCTAVE_API int __lo_ieee_float_isnan (float x);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
97 extern OCTAVE_API int __lo_ieee_float_finite (float x);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
98 extern OCTAVE_API int __lo_ieee_float_isinf (float x);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
99
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
100 extern OCTAVE_API int __lo_ieee_float_is_NA (float);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
101 extern OCTAVE_API int __lo_ieee_float_is_NaN_or_NA (float) GCC_ATTR_DEPRECATED;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
102
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
103 extern OCTAVE_API float lo_ieee_float_inf_value (void);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
104 extern OCTAVE_API float lo_ieee_float_na_value (void);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
105 extern OCTAVE_API float lo_ieee_float_nan_value (void);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
106
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
107 extern OCTAVE_API int __lo_ieee_float_signbit (float);
4349
a6c22c2c9b09 [project @ 2003-02-21 18:59:07 by jwe]
jwe
parents: 4102
diff changeset
108
4072
3cc39e3b8fa5 [project @ 2002-09-27 17:54:53 by jwe]
jwe
parents: 4025
diff changeset
109 #ifdef __cplusplus
3cc39e3b8fa5 [project @ 2002-09-27 17:54:53 by jwe]
jwe
parents: 4025
diff changeset
110 }
2522
4f095783ee43 [project @ 1996-11-15 20:00:59 by jwe]
jwe
parents: 1993
diff changeset
111 #endif
4f095783ee43 [project @ 1996-11-15 20:00:59 by jwe]
jwe
parents: 1993
diff changeset
112
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
113 #define lo_ieee_isnan(x) (sizeof (x) == sizeof (float) ? \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
114 __lo_ieee_float_isnan (x) : __lo_ieee_isnan (x))
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
115 #define lo_ieee_finite(x) (sizeof (x) == sizeof (float) ? \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
116 __lo_ieee_float_finite (x) : __lo_ieee_finite (x))
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
117 #define lo_ieee_isinf(x) (sizeof (x) == sizeof (float) ? \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
118 __lo_ieee_float_isinf (x) : __lo_ieee_isinf (x))
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
119
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
120
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
121 #define lo_ieee_is_NA(x) (sizeof (x) == sizeof (float) ? \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
122 __lo_ieee_float_is_NA (x) : __lo_ieee_is_NA (x))
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
123 #define lo_ieee_is_NaN_or_NA(x) (sizeof (x) == sizeof (float) ? \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
124 __lo_ieee_float_is_NaN_or_NA (x) : __lo_ieee_is_NaN_or_NA (x))
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
125 #define lo_ieee_signbit(x) (sizeof (x) == sizeof (float) ? \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
126 __lo_ieee_float_signbit (x) : __lo_ieee_signbit (x))
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
127
1967
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
128 #endif
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
129
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
130 /*
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
131 ;;; Local Variables: ***
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
132 ;;; mode: C++ ***
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
133 ;;; End: ***
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
134 */