Mercurial > hg > octave-nkf
annotate liboctave/lo-ieee.cc @ 14626:f947d2922feb stable rc-3-6-2-0
3.6.2-rc0 release candidate
* configure.ac (AC_INIT): Version is now 3.6.2-rc0.
(OCTAVE_RELEASE_DATE): Now 2012-05-11.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 11 May 2012 13:46:18 -0400 |
parents | 72c96de7a403 |
children |
rev | line source |
---|---|
1967 | 1 /* |
2 | |
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
3 Copyright (C) 1996-2012 John W. Eaton |
1967 | 4 |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
8 under the terms of the GNU General Public License as published by the | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
1967 | 11 |
12 Octave is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
1967 | 20 |
21 */ | |
22 | |
23 #ifdef HAVE_CONFIG_H | |
24 #include <config.h> | |
25 #endif | |
26 | |
9592
5828d64ca004
lo-ieee.cc: include cstdlib, update copyright date
John W. Eaton <jwe@octave.org>
parents:
9591
diff
changeset
|
27 #include <cstdlib> |
1967 | 28 |
11234
2718e1fdf82f
IEEE math initialization tweaks
John W. Eaton <jwe@octave.org>
parents:
11230
diff
changeset
|
29 #include <limits> |
2508 | 30 |
4698 | 31 #include "lo-error.h" |
1967 | 32 #include "lo-ieee.h" |
4025 | 33 #include "mach-info.h" |
1967 | 34 |
35 void | |
36 octave_ieee_init (void) | |
37 { | |
4601 | 38 oct_mach_info::float_format ff = oct_mach_info::native_float_format (); |
39 | |
4698 | 40 switch (ff) |
4601 | 41 { |
4698 | 42 case oct_mach_info::flt_fmt_ieee_big_endian: |
43 case oct_mach_info::flt_fmt_ieee_little_endian: | |
44 { | |
11234
2718e1fdf82f
IEEE math initialization tweaks
John W. Eaton <jwe@octave.org>
parents:
11230
diff
changeset
|
45 octave_NaN = std::numeric_limits<double>::quiet_NaN (); |
2718e1fdf82f
IEEE math initialization tweaks
John W. Eaton <jwe@octave.org>
parents:
11230
diff
changeset
|
46 octave_Inf = std::numeric_limits<double>::infinity (); |
1967 | 47 |
11234
2718e1fdf82f
IEEE math initialization tweaks
John W. Eaton <jwe@octave.org>
parents:
11230
diff
changeset
|
48 octave_Float_NaN = std::numeric_limits<float>::quiet_NaN (); |
2718e1fdf82f
IEEE math initialization tweaks
John W. Eaton <jwe@octave.org>
parents:
11230
diff
changeset
|
49 octave_Float_Inf = std::numeric_limits<float>::infinity (); |
1967 | 50 |
11234
2718e1fdf82f
IEEE math initialization tweaks
John W. Eaton <jwe@octave.org>
parents:
11230
diff
changeset
|
51 // The following is patterned after code in R. |
4698 | 52 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
53 if (ff == oct_mach_info::flt_fmt_ieee_big_endian) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
54 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
55 lo_ieee_hw = 0; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
56 lo_ieee_lw = 1; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
57 } |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
58 else |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
59 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
60 lo_ieee_hw = 1; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
61 lo_ieee_lw = 0; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
62 } |
4025 | 63 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
64 lo_ieee_double t; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
65 t.word[lo_ieee_hw] = LO_IEEE_NA_HW; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
66 t.word[lo_ieee_lw] = LO_IEEE_NA_LW; |
4698 | 67 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
68 octave_NA = t.value; |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7231
diff
changeset
|
69 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
70 lo_ieee_float tf; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
71 tf.word = LO_IEEE_NA_FLOAT; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
72 octave_Float_NA = tf.value; |
4698 | 73 } |
74 break; | |
4025 | 75 |
4698 | 76 case oct_mach_info::flt_fmt_cray: |
77 case oct_mach_info::flt_fmt_vax_d: | |
78 case oct_mach_info::flt_fmt_vax_g: | |
79 default: | |
80 // If the format is unknown, then you will probably not have a | |
9805
bb70d16cca3b
fail at configure time if IEEE floating point format is not detected
John W. Eaton <jwe@octave.org>
parents:
9592
diff
changeset
|
81 // useful system, so we will abort here. Anyone wishing to |
bb70d16cca3b
fail at configure time if IEEE floating point format is not detected
John W. Eaton <jwe@octave.org>
parents:
9592
diff
changeset
|
82 // experiment with building Octave on a system without IEEE |
bb70d16cca3b
fail at configure time if IEEE floating point format is not detected
John W. Eaton <jwe@octave.org>
parents:
9592
diff
changeset
|
83 // floating point should be capable of removing this check and |
bb70d16cca3b
fail at configure time if IEEE floating point format is not detected
John W. Eaton <jwe@octave.org>
parents:
9592
diff
changeset
|
84 // the configure test. |
9591
264fb5520973
abort if floating point format is not recognized as IEEE
John W. Eaton <jwe@octave.org>
parents:
9441
diff
changeset
|
85 (*current_liboctave_error_handler) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
86 ("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?"); |
9591
264fb5520973
abort if floating point format is not recognized as IEEE
John W. Eaton <jwe@octave.org>
parents:
9441
diff
changeset
|
87 abort (); |
4601 | 88 } |
1967 | 89 } |