lo-ieee.h

Go to the documentation of this file.
00001 /*
00002 
00003 Copyright (C) 1996-2012 John W. Eaton
00004 
00005 This file is part of Octave.
00006 
00007 Octave is free software; you can redistribute it and/or modify it
00008 under the terms of the GNU General Public License as published by the
00009 Free Software Foundation; either version 3 of the License, or (at your
00010 option) any later version.
00011 
00012 Octave is distributed in the hope that it will be useful, but WITHOUT
00013 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00015 for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with Octave; see the file COPYING.  If not, see
00019 <http://www.gnu.org/licenses/>.
00020 
00021 */
00022 
00023 #if !defined (octave_liboctave_ieee_h)
00024 #define octave_liboctave_ieee_h 1
00025 
00026 #ifdef  __cplusplus
00027 extern "C" {
00028 #endif
00029 
00030 /*  Octave's idea of infinity.  */
00031 extern OCTAVE_API double octave_Inf;
00032 
00033 /* Octave's idea of a missing value.  */
00034 extern OCTAVE_API double octave_NA;
00035 
00036 /* Octave's idea of not a number.  */
00037 extern OCTAVE_API double octave_NaN;
00038 
00039 /*  Octave's idea of infinity.  */
00040 extern OCTAVE_API float octave_Float_Inf;
00041 
00042 /* Octave's idea of a missing value.  */
00043 extern OCTAVE_API float octave_Float_NA;
00044 
00045 /* Octave's idea of not a number.  */
00046 extern OCTAVE_API float octave_Float_NaN;
00047 
00048 /* FIXME -- this code assumes that a double has twice the
00049    number of bits as an int */
00050 
00051 extern OCTAVE_API int lo_ieee_hw;
00052 extern OCTAVE_API int lo_ieee_lw;
00053 
00054 typedef union
00055 {
00056   double value;
00057   unsigned int word[2];
00058 } lo_ieee_double;
00059 
00060 typedef union
00061 {
00062   float value;
00063   unsigned int word;
00064 } lo_ieee_float;
00065 
00066 #define LO_IEEE_NA_HW_OLD 0x7ff00000
00067 #define LO_IEEE_NA_LW_OLD 1954
00068 #define LO_IEEE_NA_HW 0x7FF840F4
00069 #define LO_IEEE_NA_LW 0x40000000
00070 #define LO_IEEE_NA_FLOAT   0x7FC207A2
00071 
00072 extern OCTAVE_API void octave_ieee_init (void);
00073 
00074 extern OCTAVE_API int __lo_ieee_isnan (double x);
00075 extern OCTAVE_API int __lo_ieee_finite (double x);
00076 extern OCTAVE_API int __lo_ieee_isinf (double x);
00077 
00078 extern OCTAVE_API int __lo_ieee_is_NA (double);
00079 extern OCTAVE_API int __lo_ieee_is_old_NA (double);
00080 extern OCTAVE_API int __lo_ieee_is_NaN_or_NA (double) GCC_ATTR_DEPRECATED;
00081 extern OCTAVE_API double __lo_ieee_replace_old_NA (double);
00082 
00083 extern OCTAVE_API double lo_ieee_inf_value (void);
00084 extern OCTAVE_API double lo_ieee_na_value (void);
00085 extern OCTAVE_API double lo_ieee_nan_value (void);
00086 
00087 extern OCTAVE_API int __lo_ieee_signbit (double);
00088 
00089 extern OCTAVE_API int __lo_ieee_float_isnan (float x);
00090 extern OCTAVE_API int __lo_ieee_float_finite (float x);
00091 extern OCTAVE_API int __lo_ieee_float_isinf (float x);
00092 
00093 extern OCTAVE_API int __lo_ieee_float_is_NA (float);
00094 extern OCTAVE_API int __lo_ieee_float_is_NaN_or_NA (float) GCC_ATTR_DEPRECATED;
00095 
00096 extern OCTAVE_API float lo_ieee_float_inf_value (void);
00097 extern OCTAVE_API float lo_ieee_float_na_value (void);
00098 extern OCTAVE_API float lo_ieee_float_nan_value (void);
00099 
00100 extern OCTAVE_API int __lo_ieee_float_signbit (float);
00101 
00102 #ifdef  __cplusplus
00103 }
00104 #endif
00105 
00106 #define lo_ieee_isnan(x) (sizeof (x) == sizeof (float) ? \
00107                          __lo_ieee_float_isnan (x) : __lo_ieee_isnan (x))
00108 #define lo_ieee_finite(x) (sizeof (x) == sizeof (float) ? \
00109                            __lo_ieee_float_finite (x) : __lo_ieee_finite (x))
00110 #define lo_ieee_isinf(x) (sizeof (x) == sizeof (float) ? \
00111                           __lo_ieee_float_isinf (x) : __lo_ieee_isinf (x))
00112 
00113 
00114 #define lo_ieee_is_NA(x) (sizeof (x) == sizeof (float) ? \
00115                           __lo_ieee_float_is_NA (x) : __lo_ieee_is_NA (x))
00116 #define lo_ieee_is_NaN_or_NA(x) (sizeof (x) == sizeof (float) ? \
00117                           __lo_ieee_float_is_NaN_or_NA (x) : __lo_ieee_is_NaN_or_NA (x))
00118 #define lo_ieee_signbit(x) (sizeof (x) == sizeof (float) ? \
00119                           __lo_ieee_float_signbit (x) : __lo_ieee_signbit (x))
00120 
00121 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines