32

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
  • 515
  • 2
  • 5
  • 6

3 Answers3

51
Console.WriteLine("{0:N2}", ((double)n) / 1450);
treaschf
  • 5,788
  • 1
  • 25
  • 24
8
Console.WriteLine("{0:0.00}", 32432432423 / 1450.0);
heijp06
  • 11,558
  • 1
  • 40
  • 60
8

make use of Math.Round

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

Result: 22367194.77

GodOfNeoN
  • 45
  • 7
Pranay Rana
  • 175,020
  • 35
  • 237
  • 263