0

I have function <%= (100 / 6000 * 200) %>, but getting 0 as a result. why? It's real result is 3.333... How to get it?

Gediminas Šukys
  • 7,101
  • 7
  • 46
  • 59

1 Answers1

1

You're dividing by integers, not floats. So 100/6000 is 0.16667 which gets concatenated truncated to 0. If you divide 100.0/6000.0 you should get the answer you want.

Also, avoid doing math in your views whenever possible.

MCBama
  • 1,432
  • 10
  • 18