457
|
1 /* |
|
2 |
2847
|
3 Copyright (C) 1996, 1997 John W. Eaton |
457
|
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. |
457
|
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/>. |
457
|
20 |
|
21 */ |
|
22 |
|
23 #ifdef HAVE_CONFIG_H |
1192
|
24 #include <config.h> |
457
|
25 #endif |
|
26 |
1367
|
27 #include <cfloat> |
|
28 #include <cmath> |
457
|
29 |
|
30 #include "dbleDET.h" |
5904
|
31 #include "lo-mappers.h" |
457
|
32 |
5634
|
33 bool |
457
|
34 DET::value_will_overflow (void) const |
|
35 { |
5634
|
36 return base2 |
5904
|
37 ? (e2 + 1 > xlog2 (DBL_MAX) ? 1 : 0) |
5634
|
38 : (e10 + 1 > log10 (DBL_MAX) ? 1 : 0); |
457
|
39 } |
|
40 |
5634
|
41 bool |
457
|
42 DET::value_will_underflow (void) const |
|
43 { |
5634
|
44 return base2 |
5904
|
45 ? (e2 - 1 < xlog2 (DBL_MIN) ? 1 : 0) |
5634
|
46 : (e10 - 1 < log10 (DBL_MIN) ? 1 : 0); |
457
|
47 } |
|
48 |
5634
|
49 void |
|
50 DET::initialize10 (void) |
457
|
51 { |
5634
|
52 if (c2 != 0.0) |
|
53 { |
5904
|
54 double etmp = e2 / xlog2 (10); |
|
55 e10 = static_cast<int> (xround (etmp)); |
5634
|
56 etmp -= e10; |
|
57 c10 = c2 * pow (10.0, etmp); |
|
58 } |
457
|
59 } |
|
60 |
5634
|
61 void |
|
62 DET::initialize2 (void) |
457
|
63 { |
5634
|
64 if (c10 != 0.0) |
|
65 { |
6018
|
66 double etmp = e10 / log10 (2.0); |
5904
|
67 e2 = static_cast<int> (xround (etmp)); |
5634
|
68 etmp -= e2; |
5904
|
69 c2 = c10 * xexp2 (etmp); |
5634
|
70 } |
457
|
71 } |
|
72 |
|
73 double |
|
74 DET::value (void) const |
|
75 { |
5904
|
76 return base2 ? c2 * xexp2 (e2) : c10 * pow (10.0, e10); |
457
|
77 } |
|
78 |
|
79 /* |
|
80 ;;; Local Variables: *** |
|
81 ;;; mode: C++ *** |
|
82 ;;; End: *** |
|
83 */ |