Truncate decimal place
-
I need to do some math that involves truncating the number after the tenths place. So, I need to take some calculation and remove all digits after the first decimal place without rounding. For example 3765/3700 * 100=101.75675675675675675675675675676 But, I need to produce from that calculation 101.7. Not 101.8 (the rounded form). Is there a built in method that performs this sort of calculation, or some other way that you might suggest? Thanks.
-
I need to do some math that involves truncating the number after the tenths place. So, I need to take some calculation and remove all digits after the first decimal place without rounding. For example 3765/3700 * 100=101.75675675675675675675675675676 But, I need to produce from that calculation 101.7. Not 101.8 (the rounded form). Is there a built in method that performs this sort of calculation, or some other way that you might suggest? Thanks.
-
I need to do some math that involves truncating the number after the tenths place. So, I need to take some calculation and remove all digits after the first decimal place without rounding. For example 3765/3700 * 100=101.75675675675675675675675675676 But, I need to produce from that calculation 101.7. Not 101.8 (the rounded form). Is there a built in method that performs this sort of calculation, or some other way that you might suggest? Thanks.
-
I need to do some math that involves truncating the number after the tenths place. So, I need to take some calculation and remove all digits after the first decimal place without rounding. For example 3765/3700 * 100=101.75675675675675675675675675676 But, I need to produce from that calculation 101.7. Not 101.8 (the rounded form). Is there a built in method that performs this sort of calculation, or some other way that you might suggest? Thanks.
May not be the prettiest
double d = 101.75675675675675675675675675676; string s = string.Format("{0:f2}", d); d = Convert.ToDouble(s.Remove(s.Length-1));
Using the specifier {0:f1} still rounds the number to 101.8, so use 0:f2 and truncate it.
only two letters away from being an asset
-
I need to do some math that involves truncating the number after the tenths place. So, I need to take some calculation and remove all digits after the first decimal place without rounding. For example 3765/3700 * 100=101.75675675675675675675675675676 But, I need to produce from that calculation 101.7. Not 101.8 (the rounded form). Is there a built in method that performs this sort of calculation, or some other way that you might suggest? Thanks.
-
I need to do some math that involves truncating the number after the tenths place. So, I need to take some calculation and remove all digits after the first decimal place without rounding. For example 3765/3700 * 100=101.75675675675675675675675675676 But, I need to produce from that calculation 101.7. Not 101.8 (the rounded form). Is there a built in method that performs this sort of calculation, or some other way that you might suggest? Thanks.