33

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(????); 
0

3 Answers 3

52
Console.WriteLine("{0:N2}", ((double)n) / 1450); 
Sign up to request clarification or add additional context in comments.

Comments

8
Console.WriteLine("{0:0.00}", 32432432423 / 1450.0); 

1 Comment

this rounds automatically, so better answer than @Pranay's
8

make use of Math.Round

Console.WriteLine( Math.Round(Convert.ToDecimal(32432432423 / 1450.0), 2)); 

Result: 22367194.77

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.