+ 1

Integer vs float

What is the main the difference between both of them? Ps. Add examples please.

16th May 2017, 4:42 PM
Brunilda Vojka
Brunilda Vojka - avatar
2 ответов
+ 6
Main difference is that integers are always full numbers, whether positive or negative. They are never being confused. Floats are... weird. They are never accurate, 7.0 may sometimes be equal to 6.99999999994 and sometimes 7.0000000002. Their precision is limited. Fortunately, decent people shouldn't think too much about that :)
16th May 2017, 8:14 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 2
integer are whole number like 1, 2, 3, 424. float are fractional numbers like 1.2, 3.1415, 0.5, ...
16th May 2017, 4:53 PM
Ulisses Cruz
Ulisses Cruz - avatar