Created
May 6, 2016 08:28
-
-
Save josephkandi/2c4c6d5662c779d278da4e2c97d95643 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FloatDemo { | |
public static void main (String[] args) { | |
//A float type holds a floating point number | |
//A float is a 32-bit precision floating point number | |
//The float value should be prefixed with an F or f | |
//If you need very high precision you should use a double data type instead | |
float averageScore = 550.50F; | |
float totalScore = 975.05f; | |
System.out.println("averageScore " + averageScore); | |
System.out.println("totalScore " + totalScore); | |
//You can also use scientific notation for the literal value of the float | |
float minimumFloatValue = 1.4E-45F; | |
float maximumFloatValue = 3.4028235E38F; | |
System.out.println("minimumFloatValue " + minimumFloatValue); | |
System.out.println("maximumFloatValue " + maximumFloatValue); | |
//TODO | |
//Try removing the F at the end of the float literal values and Run again | |
//Create your own float value and print it to the console | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment