In C#, I\'m trying to get the last two decimal places of a double with NO rounding. I\'ve tried everything from Math.Floor to Math.Truncate and nothin
Math.Floor
Math.Truncate
A general solution:
public static double SignificantTruncate(double num, int significantDigits) { double y = Math.Pow(10, significantDigits); return Math.Truncate(num * y) / y; }
Then
double x = 5.3456; x = SignificantTruncate(x,2);
Will produce the desired result x=5.34.
x=5.34