0

Why is 1.0 +5 Is 6.0 why not 6

10th Jan 2017, 4:01 PM
Anuhya
3 Réponses
+ 9
Floats have more precision (not the same thing as accuracy), so the answer is converted to float.
10th Jan 2017, 4:13 PM
Kirk Schafer
Kirk Schafer - avatar
+ 2
Because float has higher precedence(of high priority than int), so automatic conversion(implicit conversion) takes place and results in a floating point value.
10th Jan 2017, 6:01 PM
Ayush Agarwal
Ayush Agarwal - avatar
+ 1
if you had 1.5+6 you'd want the answer to be 7.5 not 7.. so by default when you're adding a float to an integer, the output is a float
10th Jan 2017, 9:39 PM
ramzi
ramzi - avatar