Permalink
Browse files

Get correct default precision of 6 for the sprintf floating point for…

…mats.
  • Loading branch information...
1 parent 7559ad4 commit 9c29580c08f23aafa50de7eafd3a6f10eaa0faca @colomon colomon committed Jul 6, 2012
Showing with 5 additions and 4 deletions.
  1. +5 −4 lib/Printf.cs
View
@@ -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;
}

0 comments on commit 9c29580

Please sign in to comment.