+ 1

Float vs. Double

Can a value be at the same time double and float? Explain please I thought 14.55 was either double or float depending on the programmer's choice

2nd Feb 2020, 9:38 AM
Jack Ndabelo
Jack Ndabelo - avatar
2 Answers
+ 6
A decimal point value is always by default a double. You need to declare it as float for it be a float.
2nd Feb 2020, 9:40 AM
Avinesh
Avinesh - avatar
+ 1
You can add "f" if you want to prevent it from being a double by default: 5.4f //float 5.4 //double
2nd Feb 2020, 1:03 PM
Seb TheS
Seb TheS - avatar