+ 1
Integer vs float
What is the main the difference between both of them? Ps. Add examples please.
2 odpowiedzi
+ 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 :)
+ 2
integer are whole number like 1, 2, 3, 424.
float are fractional numbers like 1.2, 3.1415, 0.5, ...