Mercurial > hg > octave-nkf
annotate liboctave/dbleDET.cc @ 7904:1fddd9b8e862
Fix nil_rep reference counting in gl-render.cc::vertex_data internal class
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 09 Jul 2008 10:59:29 -0400 |
parents | 82be108cc558 |
children |
rev | line source |
---|---|
457 | 1 /* |
2 | |
7017 | 3 Copyright (C) 1994, 1995, 1996, 1997, 2002, 2003, 2004, 2005, 2006, |
4 2007 John W. Eaton | |
457 | 5 |
6 This file is part of Octave. | |
7 | |
8 Octave is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
457 | 12 |
13 Octave is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
457 | 21 |
22 */ | |
23 | |
24 #ifdef HAVE_CONFIG_H | |
1192 | 25 #include <config.h> |
457 | 26 #endif |
27 | |
1367 | 28 #include <cfloat> |
457 | 29 |
30 #include "dbleDET.h" | |
5904 | 31 #include "lo-mappers.h" |
7231 | 32 #include "lo-math.h" |
457 | 33 |
5634 | 34 bool |
457 | 35 DET::value_will_overflow (void) const |
36 { | |
5634 | 37 return base2 |
5904 | 38 ? (e2 + 1 > xlog2 (DBL_MAX) ? 1 : 0) |
5634 | 39 : (e10 + 1 > log10 (DBL_MAX) ? 1 : 0); |
457 | 40 } |
41 | |
5634 | 42 bool |
457 | 43 DET::value_will_underflow (void) const |
44 { | |
5634 | 45 return base2 |
5904 | 46 ? (e2 - 1 < xlog2 (DBL_MIN) ? 1 : 0) |
5634 | 47 : (e10 - 1 < log10 (DBL_MIN) ? 1 : 0); |
457 | 48 } |
49 | |
5634 | 50 void |
51 DET::initialize10 (void) | |
457 | 52 { |
5634 | 53 if (c2 != 0.0) |
54 { | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7231
diff
changeset
|
55 double etmp = e2 / xlog2 (static_cast<double>(10)); |
5904 | 56 e10 = static_cast<int> (xround (etmp)); |
5634 | 57 etmp -= e10; |
58 c10 = c2 * pow (10.0, etmp); | |
59 } | |
457 | 60 } |
61 | |
5634 | 62 void |
63 DET::initialize2 (void) | |
457 | 64 { |
5634 | 65 if (c10 != 0.0) |
66 { | |
6018 | 67 double etmp = e10 / log10 (2.0); |
5904 | 68 e2 = static_cast<int> (xround (etmp)); |
5634 | 69 etmp -= e2; |
5904 | 70 c2 = c10 * xexp2 (etmp); |
5634 | 71 } |
457 | 72 } |
73 | |
74 double | |
75 DET::value (void) const | |
76 { | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7231
diff
changeset
|
77 return base2 ? c2 * xexp2 (static_cast<double>(e2)) : c10 * pow (10.0, e10); |
457 | 78 } |
79 | |
80 /* | |
81 ;;; Local Variables: *** | |
82 ;;; mode: C++ *** | |
83 ;;; End: *** | |
84 */ |