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

Gediminas Šukys
- 7,101
- 7
- 46
- 59
-
1Change the numbers to not be integers. ex. 100 should be 100.0 – Alex Jun 13 '14 at 04:34
1 Answers
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
-
Bollocks. Yes I did. Was typing far faster than I was thinking. Thanks @muistooshort – MCBama Jun 13 '14 at 14:51