changeset 1961:41ff3c38af7e

[project @ 1996-02-16 04:03:01 by jwe]
author jwe
date Fri, 16 Feb 1996 04:04:52 +0000
parents 285a7f683a4c
children d329b8ea86e8
files liboctave/Makefile.in src/load-save.cc src/pr-output.cc src/sysdep.cc src/sysdep.h
diffstat 5 files changed, 20 insertions(+), 792 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/Makefile.in
+++ b/liboctave/Makefile.in
@@ -35,11 +35,11 @@
 INCLUDES := Bounds.h CollocWt.h DAE.h DAEFunc.h DASSL.h FEGrid.h FSQP.h \
 	LinConst.h LP.h LPsolve.h LSODE.h NLConst.h NLEqn.h NLFunc.h \
 	NLP.h NPSOL.h ODE.h ODEFunc.h Objective.h QP.h QPSOL.h Quad.h \
-	Range.h base-de.h base-min.h cmd-hist.h dir-ops.h file-ops.h \
-	f77-fcn.h getopt.h idx-vector.h lo-error.h oct-cmplx.h \
-	oct-glob.h oct-math.h oct-term.h pathsearch.h prog-args.h \
-	statdefs.h str-vec.h sun-utils.h sysdir.h \
-	$(MATRIX_INC)
+	Range.h base-de.h base-min.h byte-swap.h cmd-hist.h data-conv.h \
+	dir-ops.h file-ops.h float-fmt.h f77-fcn.h getopt.h idx-vector.h \
+	lo-error.h oct-cmplx.h oct-glob.h oct-math.h oct-term.h \
+	pathsearch.h prog-args.h statdefs.h str-vec.h sun-utils.h \
+	sysdir.h $(MATRIX_INC)
 
 TEMPLATE_SRC := Array.cc MArray.cc
 
@@ -58,10 +58,11 @@
 SOURCES := Bounds.cc CollocWt.cc DAE.cc DASSL.cc FEGrid.cc FSQP.cc \
 	LinConst.cc LPsolve.cc LSODE.cc NLEqn.cc NPSOL.cc QPSOL.cc \
 	Quad.cc Range.cc acosh.c asinh.c atanh.c cmd-hist.cc \
-	dir-ops.cc erf.c erfc.c f77-fcn.c file-ops.cc filemode.c \
-	gamma.c getopt.c getopt1.c idx-vector.cc lgamma.c \
-	mkdir.c oct-glob.cc oct-term.cc pathsearch.cc prog-args.cc \
-	rename.c rmdir.c str-vec.cc sun-utils.cc tempname.c tempnam.c \
+	data-conv.cc dir-ops.cc erf.c erfc.c f77-fcn.c file-ops.cc \
+	filemode.c float-fmt.cc gamma.c getopt.c getopt1.c \
+	idx-vector.cc lgamma.c mkdir.c oct-glob.cc oct-term.cc \
+	pathsearch.cc prog-args.cc rename.c rmdir.c str-vec.cc \
+	sun-utils.cc tempname.c tempnam.c \
 	$(TEMPLATE_SRC) \
 	$(TI_SRC) \
 	$(MATRIX_SRC)
--- a/src/load-save.cc
+++ b/src/load-save.cc
@@ -36,6 +36,9 @@
 #include <fstream.h>
 #include <strstream.h>
 
+#include "byte-swap.h"
+#include "data-conv.h"
+#include "float-fmt.h"
 #include "oct-glob.h"
 #include "str-vec.h"
 
@@ -54,26 +57,6 @@
 #include "user-prefs.h"
 #include "utils.h"
 
-#if CHAR_BIT != 8
-LOSE! LOSE!
-#endif
-
-#if SIZEOF_SHORT == 2
-#define TWO_BYTE_INT short
-#elif SIZEOF_INT == 2
-#define TWO_BYTE_INT int
-#else
-LOSE! LOSE!
-#endif
-
-#if SIZEOF_INT == 4
-#define FOUR_BYTE_INT int
-#elif SIZEOF_LONG == 4
-#define FOUR_BYTE_INT long
-#else
-LOSE! LOSE!
-#endif
-
 // Used when converting Inf to something that gnuplot can read.
 
 #ifndef OCT_RBV
@@ -88,664 +71,6 @@
     LS_UNKNOWN,
   };
 
-// Not all of the following are currently used.
-
-enum save_type
-  {
-    LS_U_CHAR,
-    LS_U_SHORT,
-    LS_U_INT,
-    LS_CHAR,
-    LS_SHORT,
-    LS_INT,
-    LS_FLOAT,
-    LS_DOUBLE,
-  };
-
-#define swap_1_bytes(x,y)
-
-#define LS_DO_READ(TYPE,swap,data,size,len,stream) \
-  do \
-    { \
-      volatile TYPE *ptr = (TYPE *) data; \
-      stream.read ((TYPE *) ptr, size * len); \
-      if (swap) \
-        swap_ ## size ## _bytes ((char *) ptr, len); \
-      TYPE tmp = ptr[0]; \
-      for (int i = len - 1; i > 0; i--) \
-        data[i] = ptr[i]; \
-      data[0] = tmp; \
-    } \
-  while (0)
-
-// Have to use copy here to avoid writing over data accessed via
-// Matrix::data().
-
-#define LS_DO_WRITE(TYPE,data,size,len,stream) \
-  do \
-    { \
-      char tmp_type = (char) type; \
-      stream.write (&tmp_type, 1); \
-      TYPE *ptr = new TYPE [len]; \
-      for (int i = 0; i < len; i++) \
-        ptr[i] = (TYPE) data[i]; \
-      stream.write ((TYPE *) ptr, size * len); \
-      delete [] ptr ; \
-    } \
-  while (0)
-
-// Loading variables from files.
-
-// But first, some data conversion routines.
-
-// Currently, we only handle conversions for the IEEE types.  To fix
-// that, make more of the following routines work.
-
-#define LS_SWAP_BYTES(i,j) \
-  tmp = t[i]; \
-  t[i] = t[j]; \
-  t[j] = tmp; \
-
-static inline void
-swap_2_bytes (char *t)
-{
-  char tmp;
-  LS_SWAP_BYTES (0, 1);
-}
-
-static inline void
-swap_4_bytes (char *t)
-{
-  char tmp;
-  LS_SWAP_BYTES (0, 3);
-  LS_SWAP_BYTES (1, 2);
-}
-
-static inline void
-swap_8_bytes (char *t)
-{
-  char tmp;
-  LS_SWAP_BYTES (0, 7);
-  LS_SWAP_BYTES (1, 6);
-  LS_SWAP_BYTES (2, 5);
-  LS_SWAP_BYTES (3, 4);
-}
-
-static inline void
-swap_2_bytes (char *t, int len)
-{
-  char *ptr = t;
-  for (int i = 0; i < len; i++)
-    {
-      swap_2_bytes (ptr);
-      ptr += 2;
-    }
-}
-
-static inline void
-swap_4_bytes (char *t, int len)
-{
-  char *ptr = t;
-  for (int i = 0; i < len; i++)
-    {
-      swap_4_bytes (ptr);
-      ptr += 4;
-    }
-}
-
-static inline void
-swap_8_bytes (char *t, int len)
-{
-  char *ptr = t;
-  for (int i = 0; i < len; i++)
-    {
-      swap_8_bytes (ptr);
-      ptr += 8;
-    }
-}
-
-// XXX FIXME XXX -- assumes sizeof (Complex) == 8
-// XXX FIXME XXX -- assumes sizeof (double) == 8
-// XXX FIXME XXX -- assumes sizeof (float) == 4
-
-static void
-IEEE_big_double_to_IEEE_little_double (double *d, int len)
-{
-  swap_8_bytes ((char *) d, len);
-}
-
-static void
-VAX_D_double_to_IEEE_little_double (double * /* d */, int /* len */)
-{
-  gripe_data_conversion ("VAX D float", "IEEE little endian format");
-}
-
-static void
-VAX_G_double_to_IEEE_little_double (double * /* d */, int /* len */)
-{
-  gripe_data_conversion ("VAX G float", "IEEE little endian format");
-}
-
-static void
-Cray_to_IEEE_little_double (double * /* d */, int /* len */)
-{
-  gripe_data_conversion ("Cray", "IEEE little endian format");
-}
-
-static void
-IEEE_big_float_to_IEEE_little_float (float *d, int len)
-{
-  swap_4_bytes ((char *) d, len);
-}
-
-static void
-VAX_D_float_to_IEEE_little_float (float * /* d */, int /* len */)
-{
-  gripe_data_conversion ("VAX D float", "IEEE little endian format");
-}
-
-static void
-VAX_G_float_to_IEEE_little_float (float * /* d */, int /* len */)
-{
-  gripe_data_conversion ("VAX G float", "IEEE little endian format");
-}
-
-static void
-Cray_to_IEEE_little_float (float * /* d */, int /* len */)
-{
-  gripe_data_conversion ("Cray", "IEEE little endian format");
-}
-
-static void
-IEEE_little_double_to_IEEE_big_double (double *d, int len)
-{
-  swap_8_bytes ((char *) d, len);
-}
-
-static void
-VAX_D_double_to_IEEE_big_double (double * /* d */, int /* len */)
-{
-  gripe_data_conversion ("VAX D float", "IEEE big endian format");
-}
-
-static void
-VAX_G_double_to_IEEE_big_double (double * /* d */, int /* len */)
-{
-  gripe_data_conversion ("VAX G float", "IEEE big endian format");
-}
-
-static void
-Cray_to_IEEE_big_double (double * /* d */, int /* len */)
-{
-  gripe_data_conversion ("Cray", "IEEE big endian format");
-}
-
-static void
-IEEE_little_float_to_IEEE_big_float (float *d, int len)
-{
-  swap_4_bytes ((char *) d, len);
-}
-
-static void
-VAX_D_float_to_IEEE_big_float (float * /* d */, int /* len */)
-{
-  gripe_data_conversion ("VAX D float", "IEEE big endian format");
-}
-
-static void
-VAX_G_float_to_IEEE_big_float (float * /* d */, int /* len */)
-{
-  gripe_data_conversion ("VAX G float", "IEEE big endian format");
-}
-
-static void
-Cray_to_IEEE_big_float (float * /* d */, int /* len */)
-{
-  gripe_data_conversion ("Cray", "IEEE big endian format");
-}
-
-static void
-IEEE_little_double_to_VAX_D_double (double * /* d */, int /* len */)
-{
-  gripe_data_conversion ("IEEE little endian", "VAX D");
-}
-
-static void
-IEEE_big_double_to_VAX_D_double (double * /* d */, int /* len */)
-{
-  gripe_data_conversion ("IEEE big endian", "VAX D");
-}
-
-static void
-VAX_G_double_to_VAX_D_double (double * /* d */, int /* len */)
-{
-  gripe_data_conversion ("VAX G float", "VAX D");
-}
-
-static void
-Cray_to_VAX_D_double (double * /* d */, int /* len */)
-{
-  gripe_data_conversion ("Cray", "VAX D");
-}
-
-static void
-IEEE_little_float_to_VAX_D_float (float * /* d */, int /* len */)
-{
-  gripe_data_conversion ("IEEE little endian", "VAX D");
-}
-
-static void
-IEEE_big_float_to_VAX_D_float (float * /* d */, int /* len */)
-{
-  gripe_data_conversion ("IEEE big endian", "VAX D");
-}
-
-static void
-VAX_G_float_to_VAX_D_float (float * /* d */, int /* len */)
-{
-  gripe_data_conversion ("VAX G float", "VAX D");
-}
-
-static void
-Cray_to_VAX_D_float (float * /* d */, int /* len */)
-{
-  gripe_data_conversion ("Cray", "VAX D");
-}
-
-static void
-IEEE_little_double_to_VAX_G_double (double * /* d */, int /* len */)
-{
-  gripe_data_conversion ("IEEE little endian", "VAX G");
-}
-
-static void
-IEEE_big_double_to_VAX_G_double (double * /* d */, int /* len */)
-{
-  gripe_data_conversion ("IEEE big endian", "VAX G");
-}
-
-static void
-VAX_D_double_to_VAX_G_double (double * /* d */, int /* len */)
-{
-  gripe_data_conversion ("VAX D float", "VAX G");
-}
-
-static void
-Cray_to_VAX_G_double (double * /* d */, int /* len */)
-{
-  gripe_data_conversion ("VAX G float", "VAX G");
-}
-
-static void
-IEEE_little_float_to_VAX_G_float (float * /* d */, int /* len */)
-{
-  gripe_data_conversion ("IEEE little endian", "VAX G");
-}
-
-static void
-IEEE_big_float_to_VAX_G_float (float * /* d */, int /* len */)
-{
-  gripe_data_conversion ("IEEE big endian", "VAX G");
-}
-
-static void
-VAX_D_float_to_VAX_G_float (float * /* d */, int /* len */)
-{
-  gripe_data_conversion ("VAX D float", "VAX G");
-}
-
-static void
-Cray_to_VAX_G_float (float * /* d */, int /* len */)
-{
-  gripe_data_conversion ("VAX G float", "VAX G");
-}
-
-static void
-do_double_format_conversion (double *data, int len,
-			     floating_point_format fmt)
-{
-  switch (native_float_format)
-    {
-    case OCTAVE_IEEE_LITTLE:
-      switch (fmt)
-	{
-	case OCTAVE_IEEE_LITTLE:
-	  break;
-
-	case OCTAVE_IEEE_BIG:
-	  IEEE_big_double_to_IEEE_little_double (data, len);
-	  break;
-
-	case OCTAVE_VAX_D:
-	  VAX_D_double_to_IEEE_little_double (data, len);
-	  break;
-
-	case OCTAVE_VAX_G:
-	  VAX_G_double_to_IEEE_little_double (data, len);
-	  break;
-
-	case OCTAVE_CRAY:
-	  Cray_to_IEEE_little_double (data, len);
-	  break;
-
-	default:
-	  gripe_unrecognized_float_fmt ();
-	  break;
-	}
-      break;
-
-    case OCTAVE_IEEE_BIG:
-      switch (fmt)
-	{
-	case OCTAVE_IEEE_LITTLE:
-	  IEEE_little_double_to_IEEE_big_double (data, len);
-	  break;
-
-	case OCTAVE_IEEE_BIG:
-	  break;
-
-	case OCTAVE_VAX_D:
-	  VAX_D_double_to_IEEE_big_double (data, len);
-	  break;
-
-	case OCTAVE_VAX_G:
-	  VAX_G_double_to_IEEE_big_double (data, len);
-	  break;
-
-	case OCTAVE_CRAY:
-	  Cray_to_IEEE_big_double (data, len);
-	  break;
-
-	default:
-	  gripe_unrecognized_float_fmt ();
-	  break;
-	}
-      break;
-
-    case OCTAVE_VAX_D:
-      switch (fmt)
-	{
-	case OCTAVE_IEEE_LITTLE:
-	  IEEE_little_double_to_VAX_D_double (data, len);
-	  break;
-
-	case OCTAVE_IEEE_BIG:
-	  IEEE_big_double_to_VAX_D_double (data, len);
-	  break;
-
-	case OCTAVE_VAX_D:
-	  break;
-
-	case OCTAVE_VAX_G:
-	  VAX_G_double_to_VAX_D_double (data, len);
-	  break;
-
-	case OCTAVE_CRAY:
-	  Cray_to_VAX_D_double (data, len);
-	  break;
-
-	default:
-	  gripe_unrecognized_float_fmt ();
-	  break;
-	}
-      break;
-
-    case OCTAVE_VAX_G:
-      switch (fmt)
-	{
-	case OCTAVE_IEEE_LITTLE:
-	  IEEE_little_double_to_VAX_G_double (data, len);
-	  break;
-
-	case OCTAVE_IEEE_BIG:
-	  IEEE_big_double_to_VAX_G_double (data, len);
-	  break;
-
-	case OCTAVE_VAX_D:
-	  VAX_D_double_to_VAX_G_double (data, len);
-	  break;
-
-	case OCTAVE_VAX_G:
-	  break;
-
-	case OCTAVE_CRAY:
-	  Cray_to_VAX_G_double (data, len);
-	  break;
-
-	default:
-	  gripe_unrecognized_float_fmt ();
-	  break;
-	}
-      break;
-
-    default:
-      panic_impossible ();
-    }
-}
-
-static void
-do_float_format_conversion (float *data, int len,
-			    floating_point_format fmt)
-{
-  switch (native_float_format)
-    {
-    case OCTAVE_IEEE_LITTLE:
-      switch (fmt)
-	{
-	case OCTAVE_IEEE_LITTLE:
-	  break;
-
-	case OCTAVE_IEEE_BIG:
-	  IEEE_big_float_to_IEEE_little_float (data, len);
-	  break;
-
-	case OCTAVE_VAX_D:
-	  VAX_D_float_to_IEEE_little_float (data, len);
-	  break;
-
-	case OCTAVE_VAX_G:
-	  VAX_G_float_to_IEEE_little_float (data, len);
-	  break;
-
-	case OCTAVE_CRAY:
-	  Cray_to_IEEE_little_float (data, len);
-	  break;
-
-	default:
-	  gripe_unrecognized_float_fmt ();
-	  break;
-	}
-      break;
-
-    case OCTAVE_IEEE_BIG:
-      switch (fmt)
-	{
-	case OCTAVE_IEEE_LITTLE:
-	  IEEE_little_float_to_IEEE_big_float (data, len);
-	  break;
-
-	case OCTAVE_IEEE_BIG:
-	  break;
-
-	case OCTAVE_VAX_D:
-	  VAX_D_float_to_IEEE_big_float (data, len);
-	  break;
-
-	case OCTAVE_VAX_G:
-	  VAX_G_float_to_IEEE_big_float (data, len);
-	  break;
-
-	case OCTAVE_CRAY:
-	  Cray_to_IEEE_big_float (data, len);
-	  break;
-
-	default:
-	  gripe_unrecognized_float_fmt ();
-	  break;
-	}
-      break;
-
-    case OCTAVE_VAX_D:
-      switch (fmt)
-	{
-	case OCTAVE_IEEE_LITTLE:
-	  IEEE_little_float_to_VAX_D_float (data, len);
-	  break;
-
-	case OCTAVE_IEEE_BIG:
-	  IEEE_big_float_to_VAX_D_float (data, len);
-	  break;
-
-	case OCTAVE_VAX_D:
-	  break;
-
-	case OCTAVE_VAX_G:
-	  VAX_G_float_to_VAX_D_float (data, len);
-	  break;
-
-	case OCTAVE_CRAY:
-	  Cray_to_VAX_D_float (data, len);
-	  break;
-
-	default:
-	  gripe_unrecognized_float_fmt ();
-	  break;
-	}
-      break;
-
-    case OCTAVE_VAX_G:
-      switch (fmt)
-	{
-	case OCTAVE_IEEE_LITTLE:
-	  IEEE_little_float_to_VAX_G_float (data, len);
-	  break;
-
-	case OCTAVE_IEEE_BIG:
-	  IEEE_big_float_to_VAX_G_float (data, len);
-	  break;
-
-	case OCTAVE_VAX_D:
-	  VAX_D_float_to_VAX_G_float (data, len);
-	  break;
-
-	case OCTAVE_VAX_G:
-	  break;
-
-	case OCTAVE_CRAY:
-	  Cray_to_VAX_G_float (data, len);
-	  break;
-
-	default:
-	  gripe_unrecognized_float_fmt ();
-	  break;
-	}
-      break;
-
-    default:
-      panic_impossible ();
-    }
-}
-
-static void
-read_doubles (istream& is, double *data, save_type type, int len,
-	      int swap, floating_point_format fmt)
-{
-  switch (type)
-    {
-    case LS_U_CHAR:
-      LS_DO_READ (unsigned char, swap, data, 1, len, is);
-      break;
-
-    case LS_U_SHORT:
-      LS_DO_READ (unsigned TWO_BYTE_INT, swap, data, 2, len, is);
-      break;
-
-    case LS_U_INT:
-      LS_DO_READ (unsigned FOUR_BYTE_INT, swap, data, 4, len, is);
-      break;
-
-    case LS_CHAR:
-      LS_DO_READ (signed char, swap, data, 1, len, is);
-      break;
-
-    case LS_SHORT:
-      LS_DO_READ (TWO_BYTE_INT, swap, data, 2, len, is);
-      break;
-
-    case LS_INT:
-      LS_DO_READ (FOUR_BYTE_INT, swap, data, 4, len, is);
-      break;
-
-    case LS_FLOAT:
-      {
-	volatile float *ptr = (float *) data;
-	is.read (data, 4 * len);
-	do_float_format_conversion ((float *) data, len, fmt);
-	float tmp = ptr[0];
-	for (int i = len - 1; i > 0; i--)
-	  data[i] = ptr[i];
-	data[0] = tmp;
-      }
-      break;
-
-    case LS_DOUBLE:
-      is.read (data, 8 * len);
-      do_double_format_conversion (data, len, fmt);
-      break;
-
-    default:
-      is.clear (ios::failbit|is.rdstate ());
-      break;
-    }
-}
-
-static void
-write_doubles (ostream& os, const double *data, save_type type, int len)
-{
-  switch (type)
-    {
-    case LS_U_CHAR:
-      LS_DO_WRITE (unsigned char, data, 1, len, os);
-      break;
-
-    case LS_U_SHORT:
-      LS_DO_WRITE (unsigned TWO_BYTE_INT, data, 2, len, os);
-      break;
-
-    case LS_U_INT:
-      LS_DO_WRITE (unsigned FOUR_BYTE_INT, data, 4, len, os);
-      break;
-
-    case LS_CHAR:
-      LS_DO_WRITE (signed char, data, 1, len, os);
-      break;
-
-    case LS_SHORT:
-      LS_DO_WRITE (TWO_BYTE_INT, data, 2, len, os);
-      break;
-
-    case LS_INT:
-      LS_DO_WRITE (FOUR_BYTE_INT, data, 4, len, os);
-      break;
-
-    case LS_FLOAT:
-      LS_DO_WRITE (float, data, 4, len, os);
-      break;
-
-    case LS_DOUBLE:
-      {
-	char tmp_type = (char) type;
-	os.write (&tmp_type, 1);
-	os.write (data, 8 * len);
-      }
-      break;
-
-    default:
-      error ("unrecognized data format requested");
-      break;
-    }
-}
-
 // Return nonzero if S is a valid identifier.
 
 static int
--- a/src/pr-output.cc
+++ b/src/pr-output.cc
@@ -36,6 +36,7 @@
 #include "CMatrix.h"
 #include "Range.h"
 #include "dMatrix.h"
+#include "float-fmt.h"
 #include "oct-cmplx.h"
 #include "oct-math.h"
 #include "oct-term.h"
--- a/src/sysdep.cc
+++ b/src/sysdep.cc
@@ -72,11 +72,11 @@
 extern char *term_clrpag;
 extern "C" void _rl_output_character_function ();
 
+#include "float-fmt.h"
 #include "oct-math.h"
 
 #include "defun.h"
 #include "error.h"
-#include "f77-fcn.h"
 #include "help.h"
 #include "input.h"
 #include "mappers.h"
@@ -87,8 +87,6 @@
 #include "toplev.h"
 #include "utils.h"
 
-extern "C" double F77_FCN (d1mach, D1MACH) (const int&);
-
 #ifndef STDIN_FILENO
 #define STDIN_FILENO 1
 #endif
@@ -99,9 +97,6 @@
 // Octave's idea of not a number.
 double octave_NaN;
 
-// The floating point format on this system.
-floating_point_format native_float_format = OCTAVE_UNKNOWN_FLT_FMT;
-
 // Nonzero if the machine we are running on is big-endian.
 int octave_words_big_endian;
 
@@ -130,39 +125,6 @@
 }
 #endif
 
-union equiv
-{
-  double d;
-  int i[2];
-};
-
-struct float_params
-{
-  floating_point_format fp_fmt;
-  equiv fp_par[4];
-};
-
-#define INIT_FLT_PAR(fp, fmt, sm1, sm2, lrg1, lrg2, rt1, rt2, dv1, dv2) \
-  do \
-    { \
-      fp.fp_fmt = (fmt); \
-      fp.fp_par[0].i[0] = (sm1);  fp.fp_par[0].i[1] = (sm2); \
-      fp.fp_par[1].i[0] = (lrg1); fp.fp_par[1].i[1] = (lrg2); \
-      fp.fp_par[2].i[0] = (rt1);  fp.fp_par[2].i[1] = (rt2); \
-      fp.fp_par[3].i[0] = (dv1);  fp.fp_par[3].i[1] = (dv2); \
-    } \
-  while (0)
-
-static int
-equiv_compare (const equiv *std, const equiv *v, int len)
-{
-  int i;
-  for (i = 0; i < len; i++)
-    if (v[i].i[0] != std[i].i[0] || v[i].i[1] != std[i].i[1])
-      return 0;
-  return 1;
-}
-
 static void
 octave_ieee_init (void)
 {
@@ -206,59 +168,6 @@
 #endif
 
 #endif
-
-  float_params fp[5];
-
-  INIT_FLT_PAR (fp[0], OCTAVE_IEEE_BIG,
-		   1048576,  0,
-		2146435071, -1,
-		1017118720,  0,
-		1018167296,  0);
-
-  INIT_FLT_PAR (fp[1], OCTAVE_IEEE_LITTLE,
-		 0,    1048576,
-		-1, 2146435071,
-		 0, 1017118720,
-		 0, 1018167296);
-
-  INIT_FLT_PAR (fp[2], OCTAVE_VAX_D,
-		   128,  0,
-		-32769, -1,
-		  9344,  0,
-		  9344,  0);
-
-  INIT_FLT_PAR (fp[3], OCTAVE_VAX_G,
-		    16,  0,
-		-32769, -1,
-		 15552,  0,
-		 15552,  0);
-
-  INIT_FLT_PAR (fp[4], OCTAVE_UNKNOWN_FLT_FMT,
-		0, 0,
-		0, 0,
-		0, 0,
-		0, 0);
-
-  equiv mach_fp_par[4];
-
-  mach_fp_par[0].d = F77_FCN (d1mach, D1MACH) (1);
-  mach_fp_par[1].d = F77_FCN (d1mach, D1MACH) (2);
-  mach_fp_par[2].d = F77_FCN (d1mach, D1MACH) (3);
-  mach_fp_par[3].d = F77_FCN (d1mach, D1MACH) (4);
-
-  int i = 0;
-  do
-    {
-      if (equiv_compare (fp[i].fp_par, mach_fp_par, 4))
-	{
-	  native_float_format = fp[i].fp_fmt;
-	  break;
-	}
-    }
-  while (fp[++i].fp_fmt != OCTAVE_UNKNOWN_FLT_FMT);
-
-  if (native_float_format == OCTAVE_UNKNOWN_FLT_FMT)
-    panic ("unrecognized floating point format!");
 }
 
 static void
@@ -319,6 +228,11 @@
 
   octave_ieee_init ();
 
+  int status = float_format_init ();
+
+  if (status < 0)
+    panic ("unrecognized floating point format!");
+
   ten_little_endians ();
 }
 
--- a/src/sysdep.h
+++ b/src/sysdep.h
@@ -44,19 +44,6 @@
 // Octave's idea of not a number.
 extern double octave_NaN;
 
-enum floating_point_format
-  {
-    OCTAVE_IEEE_LITTLE,
-    OCTAVE_IEEE_BIG,
-    OCTAVE_VAX_D,
-    OCTAVE_VAX_G,
-    OCTAVE_CRAY,
-    OCTAVE_UNKNOWN_FLT_FMT,
-  };
-
-// The floating point format on this system.
-extern floating_point_format native_float_format;
-
 // Nonzero if the machine we are running on is big-endian.
 extern int octave_words_big_endian;