Why is a suffix needed when declaring non-integer values | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
+ 1

Why is a suffix needed when declaring non-integer values

When I declare a float, I expect the number to be a float. Why do I need a suffix, to declare a float. float afloat = 1.5; https://code.sololearn.com/c8eJmM9alIlZ

17th Mar 2019, 9:15 PM
sneeze
sneeze - avatar
2 ответов
+ 1
Thanks now I understand. Because of type safety You need to define the type of the variable and also the type of the data which is gone be assigned to this variable since 1.5 is a double There has to be a way to tell the compiler, the data that is gone be assigned is a float and that is the f Thanks
18th Mar 2019, 8:27 PM
sneeze
sneeze - avatar
0
What does define if a float is a float ? By defining a float variable, you would expect the input to be a float. Why would you store by default a double in a float ? In my opnion the type of a variable is defined by its type definition.
18th Mar 2019, 8:10 PM
sneeze
sneeze - avatar