All Downloads are FREE. Search and download functionalities are using the official Maven repository.

at.spardat.enterprise.fmt.test.BigDecimalHelperTest Maven / Gradle / Ivy

There is a newer version: 6.0.2
Show newest version
/*
 * @(#) $Id: BigDecimalHelperTest.java 2582 2008-05-07 14:10:55Z webok $
 *
 * Copyright 2004/2005 by SPARDAT Sparkassen-Datendienst Ges.m.b.H.,
 * A-1110 Wien, Geiselbergstr.21-25.
 * All rights reserved.
 *
 */
package at.spardat.enterprise.fmt.test;

import java.math.BigDecimal;

import junit.framework.TestCase;
import at.spardat.enterprise.util.BigDecimalHelper;

/**
 * Run this test with JRE 1.4.2 and JRE 5.0
 * @author s3460
 * @since version_number
 */
public class BigDecimalHelperTest extends TestCase {

    protected void setUp() throws Exception {
        super.setUp();
        System.out.println("JRE Version: " + System.getProperty("java.vm.version"));
    }

    public void testBigDecimal(){
        BigDecimal bigDec = new BigDecimal("1.000000123");
        bigDec = bigDec.setScale(9, BigDecimal.ROUND_HALF_UP);

        System.out.println("1.000000123");
        System.out.println("BigDecimal:       " + bigDec.toString());
        System.out.println("BigDecimalHelper: " + BigDecimalHelper.toPlainString(bigDec));

        bigDec = new BigDecimal("0.000000123");
        bigDec = bigDec.setScale(9, BigDecimal.ROUND_HALF_UP);

        System.out.println("0.000000123");
        System.out.println("BigDecimal:       " + bigDec.toString());
        System.out.println("BigDecimalHelper: " + BigDecimalHelper.toPlainString(bigDec));
    }

    public void testBigDecimal2(){
        System.out.println(Double.MAX_VALUE);
        BigDecimal bigDec = new BigDecimal("1.7976931348623157E308");
        System.out.println("BigDecimal:       " + bigDec.toString());
        System.out.println("BigDecimalHelper: " + BigDecimalHelper.toPlainString(bigDec));

        bigDec = new BigDecimal(Double.MAX_VALUE);
        System.out.println("BigDecimal:       " + bigDec.toString());
        System.out.println("BigDecimalHelper: " + BigDecimalHelper.toPlainString(bigDec));
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy