Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Format to two decimal places [duplicate]

Tags:

c#

Possible Duplicate:
c# - How do I round a decimal value to 2 decimal places (for output on a page)

I have a number

long n = 32432432423; 

I want to divide this by 1450 and print on a console with 2 decimal places (rounded)

How can I do it?

COnsole.WriteLine(????); 
like image 435
Joe Avatar asked Jul 29 '10 06:07

Joe


People also ask

How do you make a double to two decimal places?

Just use %. 2f as the format specifier. This will make the Java printf format a double to two decimal places.


1 Answers

Console.WriteLine("{0:N2}", ((double)n) / 1450); 
like image 66
treaschf Avatar answered Sep 20 '22 23:09

treaschf