i have value of 1.564 and 1.565 i need round this value to 1.56 and 1.56,which function suitable for this in c#.
+5
A:
do a multiply by 100 followed by a floor and followed by a divide by hundred. I am sure that there is a better way of doing it though
Math.floor(n*100)/100
codebreach
2010-02-25 06:59:07
On C# that's `Floor`, by the way.
Kobi
2010-02-25 07:12:19
+2
A:
To remove the less significant digits (1.348 -> 1.34):
Math.Floor(number * 100) / 100;
To round the number to two decimals:
Math.Round(number, 2);
To represent it as a string, for display:
number.ToString("#.00");
Kobi
2010-02-25 06:59:28