Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

…mats.
  • Loading branch information...
commit 9c29580c08f23aafa50de7eafd3a6f10eaa0faca 1 parent 7559ad4
@colomon colomon authored
Showing with 5 additions and 4 deletions.
  1. +5 −4 lib/Printf.cs
View
9 lib/Printf.cs
@@ -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;
}
Please sign in to comment.
Something went wrong with that request. Please try again.