For 10 I want 10 and not 10.00 For 10.11 I want 10.11
Is this possible without code? i.e. by specifying a format string alone simlar to {0:N2}
format("%. 2f", 1.23456); This will format the floating point number 1.23456 up-to 2 decimal places, because we have used two after decimal point in formatting instruction %.
Click the Table Tools' Layout tab, select Data and then click Formula. Click the Number Format menu and select 0.00 for two decimals.
decimal num = 10.11M; Console.WriteLine( num.ToString( "0.##" ) );
It seems to me that the decimal precision is intrinsic to the decimal type, which defaults to 4 decimal places. If I use the following code:
decimal value = 8.3475M; Console.WriteLine(value); decimal newValue = decimal.Round(value, 2); Console.WriteLine(newValue);
The output is:
8.3475 8.35
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With