I dont want to round I want to take 4 places after decimal.
Example:
double something = 0.00038;
I want the result to be
0.0003 // 8 is discarded
how can I achieve that?
I dont want to round I want to take 4 places after decimal.
Example:
double something = 0.00038;
I want the result to be
0.0003 // 8 is discarded
how can I achieve that?
double result = Math.Truncate(10000 * something) / 10000;
Just multiply, truncate, then divide.
decimal f = 100.0123456;
f = Math.Truncate(f * 10000) / 10000;
Here is a nice little function you can use
public static decimal MyTruncate(decimal input, int digit) {
return Math.Truncate(input * Math.Pow(10, -digit)) / Math.Pow(10, -digit);
}
this function truncates anything to the right of the specified digit
where 0 is the ones place, 1 is the tens place and -1 is the tenths place