changeset 1759:3c615a9dcd64

(float_to_string): Add `.0' at end if needed.
author Richard M. Stallman <rms@gnu.org>
date Sun, 10 Jan 1993 20:10:26 +0000
parents 12c730b89ac8
children 05492c456293
files src/print.c
diffstat 1 files changed, 18 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/print.c	Sun Jan 10 16:44:36 1993 +0000
+++ b/src/print.c	Sun Jan 10 20:10:26 1993 +0000
@@ -581,11 +581,8 @@
 
 #ifdef LISP_FLOAT_TYPE
 
-void
-float_to_string (buf, data)
-     char *buf;
 /*
- * This buffer should be at least as large as the max string size of the
+ * The buffer should be at least as large as the max string size of the
  * largest float, printed in the biggest notation.  This is undoubtably
  * 20d float_output_format, with the negative of the C-constant "HUGE"
  * from <math.h>.
@@ -597,6 +594,10 @@
  * re-writing _doprnt to be more sane)?
  * 			-wsr
  */
+
+void
+float_to_string (buf, data)
+     char *buf;
      double data;
 {
   register unsigned char *cp, c;
@@ -638,6 +639,19 @@
 
       sprintf (buf, XSTRING (Vfloat_output_format)->data, data);
     }
+
+  /* Make sure there is a decimal point or an exponent,
+     so that the value is readable as a float.  */
+  for (cp = buf; *cp; cp++)
+    if (*cp < '0' || *cp > '9')
+      break;
+
+  if (*cp == 0)
+    {
+      *cp++ = '.';
+      *cp++ = '0';
+      *cp++ = 0;
+    }
 }
 #endif /* LISP_FLOAT_TYPE */