0

[UNANSWERED ]float

I have read many of explanations yet don't understand the point. Is float like an array of numbers and a random positioned comma? Like 123456 (put the comma where ever you like) And what's the point in such a variable?

9th Apr 2017, 9:44 AM
Alex Snaidars
Alex Snaidars - avatar
3 Respuestas
+ 3
float is a primitive data type, just like int, double, short or long in Java. Variables of this type can have values from -3.4E38 (-3.4 * 1038) to +3.4E38 (+3.4 * 1038) and occupy 4 bytes in  memory. Values are represented with approximately 7 decimal digits accuracy.
9th Apr 2017, 9:50 AM
Toni He
Toni He - avatar
+ 2
An int or long can only hold whole numbers like 1, 583, 900009 or 12 But a float can hold numbers with a fractional part like 1.04 or 4275.678 Use int if you don't need to hold fractions but float if you do. For instance if you write a program where you need to calculate the width of the screen in pixels you use an int but to hold the value of 12 divided by 17 you need a float.
9th Apr 2017, 10:11 AM
Shane
+ 1
@Shane I need double for that. @Toni Thx for the copypaste
9th Apr 2017, 10:17 AM
Alex Snaidars
Alex Snaidars - avatar