Roberto Ierusalimschy 27 лет назад
Родитель
Сommit
1917149fdd
2 измененных файлов с 8 добавлено и 3 удалено
  1. 6 1
      lobject.h
  2. 2 2
      lvm.c

+ 6 - 1
lobject.h

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lobject.h,v 1.18 1998/03/09 21:49:52 roberto Exp roberto $
+** $Id: lobject.h,v 1.19 1998/05/18 22:26:03 roberto Exp roberto $
 ** Type definitions for Lua objects
 ** Type definitions for Lua objects
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -32,6 +32,11 @@
 #define LUA_NUM_TYPE double
 #define LUA_NUM_TYPE double
 #endif
 #endif
 
 
+/*
+** format to convert number to strings
+*/
+#define NUMBER_FMT  "%g"
+
 typedef LUA_NUM_TYPE real;
 typedef LUA_NUM_TYPE real;
 
 
 #define Byte lua_Byte	/* some systems have Byte as a predefined type */
 #define Byte lua_Byte	/* some systems have Byte as a predefined type */

+ 2 - 2
lvm.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lvm.c,v 1.28 1998/03/30 13:57:23 roberto Exp roberto $
+** $Id: lvm.c,v 1.29 1998/05/31 22:18:24 roberto Exp roberto $
 ** Lua virtual machine
 ** Lua virtual machine
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -75,7 +75,7 @@ int luaV_tostring (TObject *obj)
     if ((real)(-MAX_INT) <= f && f <= (real)MAX_INT && (real)(i=(int)f) == f)
     if ((real)(-MAX_INT) <= f && f <= (real)MAX_INT && (real)(i=(int)f) == f)
       sprintf (s, "%d", i);
       sprintf (s, "%d", i);
     else
     else
-      sprintf (s, "%g", (double)nvalue(obj));
+      sprintf (s, NUMBER_FMT, nvalue(obj));
     tsvalue(obj) = luaS_new(s);
     tsvalue(obj) = luaS_new(s);
     ttype(obj) = LUA_T_STRING;
     ttype(obj) = LUA_T_STRING;
     return 0;
     return 0;