Skip to content

Commit

Permalink
Attention aux debordements de format_buffer avec %f et des grands flo…
Browse files Browse the repository at this point in the history
…ttants

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@464 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
  • Loading branch information
xleroy committed Nov 26, 1995
1 parent 2c57bdd commit 106be84
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions byterun/floats.c
Expand Up @@ -90,7 +90,12 @@ value copy_double(d)
value format_float(fmt, arg) /* ML */
value fmt, arg;
{
char format_buffer[64];
#define MAX_DIGITS 350
/* Max number of decimal digits in a "natural" (not artificially padded)
representation of a float. Can be quite big for %f format.
Max exponent for IEEE format is 308 decimal digits.
Rounded up for good measure. */
char format_buffer[MAX_DIGITS + 20];
int prec, i;
char * p;
char * dest;
Expand All @@ -99,14 +104,14 @@ value format_float(fmt, arg) /* ML */
prec = 64;
for (p = String_val(fmt); *p != 0; p++) {
if (*p >= '0' && *p <= '9') {
i = atoi(p) + 15;
i = atoi(p) + MAX_DIGITS;
if (i > prec) prec = i;
break;
}
}
for( ; *p != 0; p++) {
if (*p == '.') {
i = atoi(p+1) + 15;
i = atoi(p+1) + MAX_DIGITS;
if (i > prec) prec = i;
break;
}
Expand Down

0 comments on commit 106be84

Please sign in to comment.