Quick actions

cmd+k|ctrl+k

Navigation

Languages

BigDecimal Double Representations

Snippet info

Language

Java

Visibility

public

Author

horngyih

Created

2018-08-24T04:26:00Z

Updated

2018-08-24T04:32:58Z

import java.math.BigDecimal;

class Main {
    public static void main(String[] args) {
        System.out.println( "Value from String");
        BigDecimal zeroPointZeroFour = new BigDecimal( "0.04" );
        System.out.println( zeroPointZeroFour );
        System.out.println( zeroPointZeroFour.doubleValue() );
        System.out.println( zeroPointZeroFour.floatValue() );
        System.out.println( "END:Value from String\n");
        
        System.out.println( "Value from Double" );
        BigDecimal noughtPointNoughtFour = new BigDecimal( 0.04d );
        System.out.println( noughtPointNoughtFour );
        System.out.println( noughtPointNoughtFour.doubleValue() );
        System.out.println( noughtPointNoughtFour.floatValue() );
        System.out.println( "END:Value from Double\n" );
        
        System.out.println( "Value from Float" );
        BigDecimal ohPointOhFour = new BigDecimal( 0.04f );
        System.out.println( ohPointOhFour );
        System.out.println( ohPointOhFour.doubleValue() );
        System.out.println( ohPointOhFour.floatValue() );
        System.out.println( "END:Value from Float\n" );
    }
}
INFO