-4

I doing a simple calculation from 2 variable and I got in to an issue... In fact when I try to do " double d = 1000 (which is the first var) / 3600 (which is the 2nd var); it result in a 0. So why ? Any hint about that ?

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
ZeTioZ
  • 1
  • 3

1 Answers1

1

1000 and 3600 are ints, so when you do 1000 / 3600 you get 0. Then, you are assigning double d to this result of zero. You can instead write 1000.0/3600.0 or if these two numbers are variables, you can cast them to doubles first.

jsones
  • 91
  • 4