Float and Double primitive type.

Floating number : - Unlike Integer number floating number has fraction part or decimal. Ex - 3.23434


We used floating when more precision is needed. In java we have two primitive type number to represent floating number are Float and Double. Float is single precision number while double s double precision number. Here precision means format and size(Space). 

Now you know float is single precision and it occupies 32 bits space where as Double is double precision and occupies 64 bits.


package com.ekumeedhelp;

public class PrimitiveDataType2 {

public static void main(String[] args) {

float minFloatValue = Float.MIN_VALUE;
float maxFloatValue = Float.MAX_VALUE;

System.out.println("Min Float Value : " + minFloatValue);
System.out.println("Max Float Value : " + maxFloatValue);

double minDoubleValue = Double.MIN_VALUE;
double maxDoubleValue = Double.MAX_VALUE;

System.out.println("Min Double Value : " + minDoubleValue);
System.out.println("Max Double Value : " + maxDoubleValue);

}

}

Share this

Related Posts

Previous
Next Post »