Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Get correct default precision of 6 for the sprintf floating point for…
…mats.
  • Loading branch information
colomon committed Jul 6, 2012
1 parent 7559ad4 commit 9c29580
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/Printf.cs
Expand Up @@ -266,17 +266,18 @@ private struct PrintfFormat {
f = -f;
}

double log;
int precision = format.precision > 0 ? format.precision : 6;

String number = "??";
switch (format.directive) {
case PrintfDirective.FloatFixedDecimal:
number = f.ToString("F" + format.precision);
number = f.ToString("F" + precision);
break;
case PrintfDirective.FloatScientific:
number = f.ToString("e" + format.precision);
number = f.ToString("e" + precision);
break;
case PrintfDirective.FloatEF:
number = f.ToString("g" + format.precision);
number = f.ToString("g" + precision);
break;
}

Expand Down

0 comments on commit 9c29580

Please sign in to comment.