Java-Floating Point

Floating Point Types

Integer types can hold only whole numbers and therefore we use another type known as floating point type to hold numbers containing fractional parts such as 50.55 and 2.344. There are two kinds of floating point storage in Java.

Type Size Description
float 4 byte The type float specifies a single-precision value. Variable of type float are useful when you need a fractional component, but don’t require a large degree of precision. We can make float by appending the letter ‘f’ at the end of the number.
double 8 byte Double precision, as denoted by the double keyword. Double precision types are used when we need greater precision in storage of floating point numbers.



Program Source

class Javaapp {

    public static void main(String[] args) {
        float  flo=10.345487277627762f;
        double dou=10.4645287277627762;
        System.out.println("flo : "+flo);
        System.out.println("dou : "+dou);

Leave a Comment