as I understand format with precision works like round(float,precision), so this code run bad (from time to time)
var f1 = 1.545, f2=1.445;
SYS.println(MAT.round(f1) + " " + MAT.round(f2));
SYS.println(f1.format("%.0f") + " " + f2.format("%.0f"));
SYS.println(f1.format("%.1f") + " " + f2.format("%.1f"));
SYS.println(f1.format("%.2f") + " " + f2.format("%.2f"));
SYS.println(f1.format("%.3f") + " " + f2.format("%.3f"));
f1 = 1.51;
for(var i = 0; i < 10; i++)
{
f2 = f1 + 0.001*i;
SYS.println(f2 + " " + f2.format("%.2f"));
}
console
2.000000 1.000000
2 1
1.5 1.4
1.54 1.45 bug - should be 1.55 1.45 (but why 1.445 is rounding well but not 1.545)
1.545 1.445
1.510000 1.51
1.511000 1.51
1.512000 1.51
1.513000 1.51
1.514000 1.51
1.515000 1.51 bug should be 1.52
1.516000 1.52
1.517000 1.52
1.518000 1.52
1.519000 1.52