Code example for BigDecimal

Methods: signum

0
     * signum() for a positive BigDecimal 
     */ 
    public void testSignumPositive() { 
       String a = "92948782094488478231212478987482988429808779810457634781384756794987";
       int aScale = 41;
       BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
       assertEquals("incorrect value", 1, aNumber.signum());
    } 
 
    /** 
     * signum() for a negative BigDecimal 
     */ 
    public void testSignumNegative() { 
       String a = "-92948782094488478231212478987482988429808779810457634781384756794987";
       int aScale = 41;
       BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
       assertEquals("incorrect value", -1, aNumber.signum());
    } 
 
    /** 
     * signum() for zero