diff --git a/src/encode.c b/src/encode.c
index 760008fd331efc98ae28918ac94b5bb4c93ff7c5..dac9decf5232228c65a576f59b763d93487b1c3a 100644
--- a/src/encode.c
+++ b/src/encode.c
@@ -28,25 +28,13 @@
 
 #include <math.h>
 
-#ifdef HAVE_FREXP
-#define FREXP frexp
-#else
-double frexp(double x, int *exp)
-{
-  double ret;
-  *exp=(int)ceil(log(x)/log(2.0));
-  ret=(x*pow(2.0,(float)-*exp));
-  return ret;
-}
-#endif
-
 #ifdef HAVE_FREXP
 #define FREXP frexp
 #else
 double FREXP(double x, int *exp)
 {
   double ret;
-  *exp=(int)ceil(log(x)/log(2.0));
+  *exp=(int)ceil(log(fabs(x))/log(2.0));
   ret=(x*pow(2.0,(float)-*exp));
   return ret;
 }
diff --git a/src/testsuite.in b/src/testsuite.in
index 5f71a4e32c5011bc31653391fbe60f9d40bba3fe..97ca99ca3e60e6ed85402426f35c808071c219f6 100644
--- a/src/testsuite.in
+++ b/src/testsuite.in
@@ -1,4 +1,4 @@
-test_true([["$Id: testsuite.in,v 1.59 1997/10/10 20:22:02 hubbe Exp $"]])
+test_true([["$Id: testsuite.in,v 1.60 1997/10/19 22:13:33 hubbe Exp $"]])
 test_eq(1e1,10.0)
 test_eq(1E1,10.0)
 test_eq(1e+1,10.0)
@@ -47,6 +47,7 @@ test_encode(0)
 test_encode("")
 test_encode(0.0)
 test_encode(1.0)
+test_encode(-1.0)
 test_encode(12.0)
 test_encode(100000.0)
 test_encode(3.14159265)