+ 1

Why would we write 4 like 4.0?

2nd Nov 2018, 12:53 PM
Juveman
Juveman - avatar
6 Respostas
+ 7
4.0 and 4 wouldnt make much of a diffrenece but floating points are used for better precision
2nd Nov 2018, 1:18 PM
D_Stark
D_Stark - avatar
+ 3
Why you asserting that?
2nd Nov 2018, 1:12 PM
KrOW
KrOW - avatar
+ 3
Can you elaborate it?
2nd Nov 2018, 1:15 PM
Muhd Khairul Amirin
Muhd Khairul Amirin - avatar
+ 3
Juveman From Python 3, creators have decided that integer divisions would return always float though int would be enough... Maybe because in this way its more easy to get more precise result without use casts P.S. In python versions < 3, integer division return an integer like you expect
2nd Nov 2018, 1:40 PM
KrOW
KrOW - avatar
+ 1
I am saying, in real world 6 / 2 equals 3 right? why in python should we make it 3.0?
2nd Nov 2018, 1:23 PM
Juveman
Juveman - avatar
+ 1
KrOW I c. thx
2nd Nov 2018, 1:50 PM
Juveman
Juveman - avatar