-1

I need to split a number with decimal places.
An example: I need to do 14525/1024/1024 but in my application, it says

0 MB

How to calculate 14525/1024/1024 to

00,01 MB

like

40.61 MB

(I need to convert bytes to megabytes)

2 Answers2

1

You need to use decimal and not int:

decimal result = Math.Round((decimal)14525 / 1024 / 1024, 2);
Zein Makki
  • 29,485
  • 6
  • 52
  • 63
0

cast any value to Double before to do the division

lem2802
  • 1,152
  • 7
  • 18