Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

To display Number With 2 Decimal Places

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?

like image 626
user42348 Avatar asked Aug 20 '09 05:08

user42348


People also ask

How do you show two decimal places?

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.

How do I format to 2 decimal places in Word?

Click the Table Tools' Layout tab, select Data and then click Formula. Click the Number Format menu and select 0.00 for two decimals.

How do you print 2 decimal places only?

format() with “{:. 2f}” as string and float as a number. Call print and it will print the float with 2 decimal places.

How do you format cells to display the numbers to two 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.


1 Answers

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
like image 182
Ramesh Soni Avatar answered Oct 03 '22 09:10

Ramesh Soni