0

5/2 = 2

x=5 y=2 #Division puts x/y #outputs 2 How come it could be "2"?

8th Sep 2017, 10:05 PM
Sebastian Czarnecki
Sebastian Czarnecki - avatar
5 Answers
+ 2
i did a lil test and changed x=5 to x=5.0 and that worked.
8th Sep 2017, 10:23 PM
Enzo
Enzo - avatar
+ 3
What do you mean you can't test it yourself?
8th Sep 2017, 11:12 PM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 2
idk ruby but can you turn it into a float? Im guessing it drops the decimal.
8th Sep 2017, 10:20 PM
Enzo
Enzo - avatar
+ 2
Thx a lot!
8th Sep 2017, 10:24 PM
Sebastian Czarnecki
Sebastian Czarnecki - avatar
+ 1
You are dividing two ints and the result will be... another int. If you use floats then the result will be another float and won't get truncated.
9th Sep 2017, 12:19 AM
Daniel de Lizaur