0

why is 15 wrong when the answer is 15.0

I understand floats but 4.0 + 3 = 7 or 7.0...same thing!

15th Jul 2019, 3:55 AM
Joseph D
Joseph D - avatar
3 ответов
0
7 equals 7.0. That is true. But if the question is what the output will be, then you have to be precise, and pay attention to the data types.
15th Jul 2019, 4:42 AM
Heather
Heather - avatar
0
In science the answer to 4.0 + 3 would be 7 because you need to pay attention to the significant digits. But in coding it is all about data types.
15th Jul 2019, 4:46 AM
Heather
Heather - avatar
0
ok thank you
17th Jul 2019, 9:16 PM
Joseph D
Joseph D - avatar