Mercurial > hg > octave-nkf
changeset 4072:3cc39e3b8fa5
[project @ 2002-09-27 17:54:53 by jwe]
author | jwe |
---|---|
date | Fri, 27 Sep 2002 17:54:53 +0000 |
parents | 3827a03c72f0 |
children | 38a22328f192 |
files | liboctave/ChangeLog liboctave/Makefile.in liboctave/lo-cieee.c liboctave/lo-ieee.cc liboctave/lo-ieee.h |
diffstat | 5 files changed, 136 insertions(+), 55 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,19 @@ +2002-09-27 John W. Eaton <jwe@bevo.che.wisc.edu> + + * Makefile.in (LIBOCTAVE_C_SOURCES): Add lo-cieee.c to the list. + * lo-cieee.c: New file. + (lo_ieee_is_NaN_or_NA): Move here from lo-ieee.cc. + (lo_ieee_is_NA): Likewise. + [SCO] (isinf, isnan): Likewise. + * lo-ieee.h: Now all extern "C". + (LO_IEEE_NA_HW, LO_IEEE_NA_LW): Move here from lo-ieee.cc and + rename from NA_HW and NA_LW. + (lo_ieee_double): Move typedef here from lo-ieee.cc and rename + from ieee_double. + (lo_ieee_hw, lo_ieee_low): Provide decl. + * lo-ieee.cc (lo_ieee_hw, lo_ieee_low): Rename from hw and lw. + Now extern. + 2002-09-26 John W. Eaton <jwe@bevo.che.wisc.edu> * Array.cc, Array.h, Array2.cc, Array2.h, Array3.cc, Array3.h,
--- a/liboctave/Makefile.in +++ b/liboctave/Makefile.in @@ -109,8 +109,8 @@ $(VX_OP_SRC) LIBOCTAVE_C_SOURCES := f2c-main.c filemode.c getopt.c getopt1.c \ - lo-cutils.c mkdir.c oct-getopt.c rename.c rmdir.c strftime.c \ - strptime.c tempname.c tempnam.c + lo-cieee.c lo-cutils.c mkdir.c oct-getopt.c rename.c \ + rmdir.c strftime.c strptime.c tempname.c tempnam.c LIBOCTAVE_SOURCES := $(LIBOCTAVE_CXX_SOURCES) $(LIBOCTAVE_C_SOURCES)
new file mode 100644 --- /dev/null +++ b/liboctave/lo-cieee.c @@ -0,0 +1,84 @@ +/* + +Copyright (C) 2002 John W. Eaton + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) any +later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <float.h> +#include <math.h> + +#if defined (HAVE_FLOATINGPOINT_H) +#include <floatingpoint.h> +#endif + +#if defined (HAVE_IEEEFP_H) +#include <ieeefp.h> +#endif + +#if defined (HAVE_NAN_H) +#if defined (SCO) +#define _IEEE 1 +#endif +#include <nan.h> +#if defined (SCO) +#undef _IEEE +#endif +#endif + +#include "lo-ieee.h" + +#if defined (SCO) + +int +isnan (double x) +{ + return (IsNANorINF (x) && NaN (x) && ! IsINF (x)) ? 1 : 0; +} + +int +isinf (double x) +{ + return (IsNANorINF (x) && IsINF (x)) ? 1 : 0; +} + +#endif + +int +lo_ieee_is_NA (double x) +{ + lo_ieee_double t; + t.value = x; + return (isnan (x) && t.word[lo_ieee_lw] == LO_IEEE_NA_LW) ? 1 : 0; +} + +int +lo_ieee_is_NaN_or_NA (double x) +{ + return isnan (x); +} + +/* +;;; Local Variables: *** +;;; mode: C++ *** +;;; End: *** +*/
--- a/liboctave/lo-ieee.cc +++ b/liboctave/lo-ieee.cc @@ -57,17 +57,8 @@ // Octave's idea of a missing value. double octave_NA; -static int hw; -static int lw; - -typedef union -{ - double value; - unsigned int word[2]; -} ieee_double; - -#define NA_HW 0x7ff00000 -#define NA_LW 1954 +int lo_ieee_hw; +int lo_ieee_lw; void octave_ieee_init (void) @@ -112,54 +103,24 @@ if (ff == oct_mach_info::ieee_big_endian) { - hw = 0; - lw = 1; + lo_ieee_hw = 0; + lo_ieee_lw = 1; } else { - hw = 1; - lw = 0; + lo_ieee_hw = 1; + lo_ieee_lw = 0; } - ieee_double t; - t.word[hw] = NA_HW; - t.word[lw] = NA_LW; + lo_ieee_double t; + t.word[lo_ieee_hw] = LO_IEEE_NA_HW; + t.word[lo_ieee_lw] = LO_IEEE_NA_LW; octave_NA = t.value; #endif } -#if defined (SCO) - -extern "C" int -isnan (double x) -{ - return (IsNANorINF (x) && NaN (x) && ! IsINF (x)) ? 1 : 0; -} - -extern "C" int -isinf (double x) -{ - return (IsNANorINF (x) && IsINF (x)) ? 1 : 0; -} - -#endif - -extern "C" int -lo_ieee_is_NA (double x) -{ - ieee_double t; - t.value = x; - return (isnan (x) && t.word[lw] == NA_LW) ? 1 : 0; -} - -extern "C" int -lo_ieee_is_NaN_or_NA (double x) -{ - return isnan (x); -} - /* ;;; Local Variables: *** ;;; mode: C++ ***
--- a/liboctave/lo-ieee.h +++ b/liboctave/lo-ieee.h @@ -23,6 +23,10 @@ #if !defined (octave_liboctave_ieee_h) #define octave_liboctave_ieee_h 1 +#ifdef __cplusplus +extern "C" { +#endif + // Octave's idea of infinity. extern double octave_Inf; @@ -32,14 +36,30 @@ // Octave's idea of a missing value. extern double octave_NA; -extern void octave_ieee_init (void); +void octave_ieee_init (void); -extern "C" int lo_ieee_is_NA (double); -extern "C" int lo_ieee_is_NaN_or_NA (double); +int lo_ieee_is_NA (double); +int lo_ieee_is_NaN_or_NA (double); #if defined (SCO) -extern "C" int isnan (double); -extern "C" int isinf (double); +int isnan (double); +int isinf (double); +#endif + +extern int lo_ieee_hw; +extern int lo_ieee_lw; + +typedef union +{ + double value; + unsigned int word[2]; +} lo_ieee_double; + +#define LO_IEEE_NA_HW 0x7ff00000 +#define LO_IEEE_NA_LW 1954 + +#ifdef __cplusplus +} #endif #endif