annotate liboctave/util/lo-ieee.cc @ 26376:00f796120a6d stable

maint: Update copyright dates in all source files.
author John W. Eaton <jwe@octave.org>
date Wed, 02 Jan 2019 16:32:43 -0500
parents 6652d3823428
children 6bfed6e4e9e9
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
26376
00f796120a6d maint: Update copyright dates in all source files.
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
3 Copyright (C) 1996-2019 John W. Eaton
1967
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
4
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
5 This file is part of Octave.
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
6
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23662
diff changeset
7 Octave is free software: you can redistribute it and/or modify it
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
8 under the terms of the GNU General Public License as published by
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23662
diff changeset
9 the Free Software Foundation, either version 3 of the License, or
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
10 (at your option) any later version.
1967
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
11
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
12 Octave is distributed in the hope that it will be useful, but
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
13 WITHOUT ANY WARRANTY; without even the implied warranty of
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
15 GNU General Public License for more details.
1967
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
16
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
17 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: 5307
diff changeset
18 along with Octave; see the file COPYING. If not, see
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23662
diff changeset
19 <https://www.gnu.org/licenses/>.
1967
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
20
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
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
23 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21202
diff changeset
24 # include "config.h"
1967
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
25 #endif
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
26
18540
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
27 #include <cmath>
23448
e1c02e7126a9 avoid calling abort if possible; include cstdlib for declaration if needed
John W. Eaton <jwe@octave.org>
parents: 23443
diff changeset
28 #include <cstdlib>
1967
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
29
11234
2718e1fdf82f IEEE math initialization tweaks
John W. Eaton <jwe@octave.org>
parents: 11230
diff changeset
30 #include <limits>
2508
f8d5dbbbc50a [project @ 1996-11-13 17:21:07 by jwe]
jwe
parents: 1993
diff changeset
31
23662
bd77ab816e43 eliminate obsolete file lo-math.h
John W. Eaton <jwe@octave.org>
parents: 23622
diff changeset
32 #include "lo-error.h"
bd77ab816e43 eliminate obsolete file lo-math.h
John W. Eaton <jwe@octave.org>
parents: 23622
diff changeset
33 #include "lo-ieee.h"
bd77ab816e43 eliminate obsolete file lo-math.h
John W. Eaton <jwe@octave.org>
parents: 23622
diff changeset
34 #include "mach-info.h"
bd77ab816e43 eliminate obsolete file lo-math.h
John W. Eaton <jwe@octave.org>
parents: 23622
diff changeset
35
18540
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
36 static double lo_inf;
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
37 static double lo_nan;
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
38 static double lo_na;
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
39
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
40 static float lo_float_inf;
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
41 static float lo_float_nan;
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
42 static float lo_float_na;
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
43
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
44 static int lo_ieee_hw;
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
45 static int lo_ieee_lw;
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
46
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
47 int
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
48 __lo_ieee_is_NA (double x)
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
49 {
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
50 lo_ieee_double t;
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
51 t.value = x;
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
52 return (__lo_ieee_isnan (x) && t.word[lo_ieee_hw] == LO_IEEE_NA_HW
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
53 && t.word[lo_ieee_lw] == LO_IEEE_NA_LW) ? 1 : 0;
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
54 }
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
55
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
56 int
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
57 __lo_ieee_is_old_NA (double x)
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
58 {
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
59 lo_ieee_double t;
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
60 t.value = x;
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
61 return (__lo_ieee_isnan (x) && t.word[lo_ieee_lw] == LO_IEEE_NA_LW_OLD
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
62 && t.word[lo_ieee_hw] == LO_IEEE_NA_HW_OLD) ? 1 : 0;
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
63 }
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
64
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
65 double
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
66 __lo_ieee_replace_old_NA (double x)
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
67 {
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
68 if (__lo_ieee_is_old_NA (x))
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
69 return lo_ieee_na_value ();
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
70 else
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
71 return x;
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
72 }
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
73
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
74 double
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
75 lo_ieee_inf_value (void)
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
76 {
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
77 octave_ieee_init ();
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
78
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
79 return lo_inf;
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
80 }
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
81
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
82 double
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
83 lo_ieee_na_value (void)
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
84 {
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
85 octave_ieee_init ();
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
86
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
87 return lo_na;
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
88 }
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
89
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
90 double
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
91 lo_ieee_nan_value (void)
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
92 {
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
93 octave_ieee_init ();
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
94
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
95 return lo_nan;
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
96 }
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
97
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
98 int
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
99 __lo_ieee_float_is_NA (float x)
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
100 {
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
101 lo_ieee_float t;
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
102 t.value = x;
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
103 return (__lo_ieee_float_isnan (x) && (t.word == LO_IEEE_NA_FLOAT)) ? 1 : 0;
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
104 }
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
105
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
106 float
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
107 lo_ieee_float_inf_value (void)
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
108 {
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
109 octave_ieee_init ();
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
110
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
111 return lo_float_inf;
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
112 }
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
113
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
114 float
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
115 lo_ieee_float_na_value (void)
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
116 {
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
117 octave_ieee_init ();
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
118
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
119 return lo_float_na;
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
120 }
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
121
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
122 float
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
123 lo_ieee_float_nan_value (void)
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
124 {
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
125 octave_ieee_init ();
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
126
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
127 return lo_float_nan;
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
128 }
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
129
1967
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
130 void
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
131 octave_ieee_init (void)
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
132 {
18540
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
133 bool initialized = false;
1967
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
134
18540
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
135 if (! initialized)
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
136 {
21739
c4ab2e54f100 use namespace for oct_mach_info class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
137 octave::mach_info::float_format ff = octave::mach_info::native_float_format ();
4698
737fd5c0ae06 [project @ 2004-01-19 19:25:26 by jwe]
jwe
parents: 4603
diff changeset
138
18540
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
139 switch (ff)
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
140 {
21739
c4ab2e54f100 use namespace for oct_mach_info class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
141 case octave::mach_info::flt_fmt_ieee_big_endian:
c4ab2e54f100 use namespace for oct_mach_info class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
142 case octave::mach_info::flt_fmt_ieee_little_endian:
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
143 {
18540
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
144 lo_nan = std::numeric_limits<double>::quiet_NaN ();
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
145 lo_inf = std::numeric_limits<double>::infinity ();
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
146
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
147 lo_float_nan = std::numeric_limits<float>::quiet_NaN ();
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
148 lo_float_inf = std::numeric_limits<float>::infinity ();
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
149
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
150 // The following is patterned after code in R.
4025
cfb762dc9259 [project @ 2002-08-09 06:32:15 by jwe]
jwe
parents: 3475
diff changeset
151
21739
c4ab2e54f100 use namespace for oct_mach_info class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
152 if (ff == octave::mach_info::flt_fmt_ieee_big_endian)
18540
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
153 {
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
154 lo_ieee_hw = 0;
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
155 lo_ieee_lw = 1;
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
156 }
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
157 else
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
158 {
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
159 lo_ieee_hw = 1;
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
160 lo_ieee_lw = 0;
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
161 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
162
18540
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
163 lo_ieee_double t;
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
164 t.word[lo_ieee_hw] = LO_IEEE_NA_HW;
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
165 t.word[lo_ieee_lw] = LO_IEEE_NA_LW;
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
166
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
167 lo_na = t.value;
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
168
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
169 lo_ieee_float tf;
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
170 tf.word = LO_IEEE_NA_FLOAT;
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
171
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
172 lo_float_na = tf.value;
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
173 }
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
174 break;
4025
cfb762dc9259 [project @ 2002-08-09 06:32:15 by jwe]
jwe
parents: 3475
diff changeset
175
18540
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
176 default:
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
177 // If the format is unknown, then you will probably not have a
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
178 // useful system, so we will abort here. Anyone wishing to
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
179 // experiment with building Octave on a system without IEEE
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
180 // floating point should be capable of removing this check and
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
181 // the configure test.
23448
e1c02e7126a9 avoid calling abort if possible; include cstdlib for declaration if needed
John W. Eaton <jwe@octave.org>
parents: 23443
diff changeset
182 //
e1c02e7126a9 avoid calling abort if possible; include cstdlib for declaration if needed
John W. Eaton <jwe@octave.org>
parents: 23443
diff changeset
183 // If the the error handler returns, then we'll abort.
e1c02e7126a9 avoid calling abort if possible; include cstdlib for declaration if needed
John W. Eaton <jwe@octave.org>
parents: 23443
diff changeset
184
18540
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
185 (*current_liboctave_error_handler)
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
186 ("lo_ieee_init: floating point format is not IEEE! Maybe DLAMCH is miscompiled, or you are using some strange system without IEEE floating point math?");
23448
e1c02e7126a9 avoid calling abort if possible; include cstdlib for declaration if needed
John W. Eaton <jwe@octave.org>
parents: 23443
diff changeset
187
18540
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
188 abort ();
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
189 }
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
190
89bd70fae066 fix initialization problem for Inf, NaN, and NA values (bug #41667)
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
191 initialized = true;
4601
1ed6cfbc8ea4 [project @ 2003-11-12 18:30:29 by jwe]
jwe
parents: 4574
diff changeset
192 }
1967
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
193 }