Skip to content

Instantly share code, notes, and snippets.

@josephkandi
Created May 6, 2016 08:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save josephkandi/2c4c6d5662c779d278da4e2c97d95643 to your computer and use it in GitHub Desktop.
Save josephkandi/2c4c6d5662c779d278da4e2c97d95643 to your computer and use it in GitHub Desktop.
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