30

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(????);
Community
  • 1
  • 1
Joe
  • 485
  • 2
  • 5
  • 6

3 Answers3

50
Console.WriteLine("{0:N2}", ((double)n) / 1450);
treaschf
  • 5,558
  • 1
  • 24
  • 24
8

make use of Math.Round

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

Result: 22367194.77

GodOfNeoN
  • 45
  • 6
Pranay Rana
  • 170,430
  • 35
  • 234
  • 261
7
Console.WriteLine("{0:0.00}", 32432432423 / 1450.0);
heijp06
  • 11,182
  • 1
  • 38
  • 59