I have a field in datatable .If 1000 is the value in it, i want to display it as 1000.00.Then if user changes to 1000.50 it should display as it is.Is there anyway to do this?Can anybody help?
4.737 rounded to 2 decimal places would be 4.74 (because it would be closer to 4.74). 4.735 is halfway between 4.73 and 4.74, so it is rounded up: 4.735 rounded to 2 decimal places is 4.74.
Click the Table Tools' Layout tab, select Data and then click Formula. Click the Number Format menu and select 0.00 for two decimals.
format() with “{:. 2f}” as string and float as a number. Call print and it will print the float with 2 decimal places.
Select the cells that you want to format. On the Home tab, click Increase Decimal or Decrease Decimal to show more or fewer digits after the decimal point.
Sample Code:
Dim bigNumber As Decimal = 1234567.123456
Console.WriteLine("F2: " & bigNumber.ToString("F2"))
Console.WriteLine("N2: " & bigNumber.ToString("N2"))
Output:
F2: 1234567.12
N2: 1,234,567.12
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