Hi,

At Thu, 17 Apr 2003 02:13:33 +0900,
Rudi Cilibrasi wrote:
> This technique would allow me to do long scientific simulations 
> that have to load and save lots of intermediate files and over 
> many different computers working in parallel and communicating 
> results via network.

What about just adding an extra digit than DBL_DIG?

Yet another idea is to use original binary format: divide the
value into sign, exponent and mantissa, then encode them
severally.


Index: marshal.c =================================================================== RCS file: //sharui/cvs/ruby/src/ruby/marshal.c,v retrieving revision 1.84 diff -u -2 -p -r1.84 marshal.c --- marshal.c 9 Apr 2003 05:08:25 -0000 1.84 +++ marshal.c 16 Apr 2003 17:45:32 -0000 @@ -17,4 +17,7 @@ #include <math.h> +#ifdef HAVE_FLOAT_H +#include <float.h> +#endif #define BITSPERSHORT (2*CHAR_BIT) @@ -75,4 +78,10 @@ shortlen(len, ds) #define TYPE_LINK '@' +#ifdef DBL_DIG +#define FLOAT_PRECISION (DBL_DIG+2) +#else +#define FLOAT_PRECISION 17 +#endif + static ID s_dump, s_load; static ID s_dump_data, s_load_data, s_alloc; @@ -202,5 +211,5 @@ w_float(d, arg) else { /* xxx: should not use system's sprintf(3) */ - sprintf(buf, "%.16g", d); + sprintf(buf, "%.*g", FLOAT_PRECISION, d); } w_bytes(buf, strlen(buf), arg);
-- Nobu Nakada