Feedback

what's your question? be descriptive.

  • Current version

    Back

    Pues es solo hacer un round_down, funciona para negativos y positivos como muestro a continuacion

    package com.alliensoft.workflow.testclasses;
    
    import java.math.BigDecimal;
    import java.text.DecimalFormat;
    import java.text.NumberFormat;
    import java.util.Hashtable;
    
    
    /**
     * Date 9/03/2010.10:38:01
     * <p> pruebas de bigDecimal
     * @author pescamilla
     */
    public class TestTest {
    
        /**
         * Date 9/03/2010.10:38:01
         * @author pescamilla
         * @throws Exception Cualquier error ejecutando el constructor de cualquier prueba
         */
        public TestTest() throws Exception {
            int decimalPlaces = 2;
            BigDecimal bd = new BigDecimal("-123456789.0193456890");
            BigDecimal bd2 = new BigDecimal("123456789.0193456890");
            bd = bd.setScale(decimalPlaces, BigDecimal.ROUND_DOWN);
            bd2 = bd2.setScale(decimalPlaces, BigDecimal.ROUND_DOWN);
            System.out.println(bd.toString());
            System.out.println(bd2.toString());
        }
    
        /**
         * Date 9/03/2010.10:38:01
         * <p>Clase main
         * @author pescamilla
         * @param args argumentos no necesarios
         */
        public static void main(String[] args) {
            try {
                new TestTest();
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
    
        }
    }
    

    By: David Cuadrado [ Admin ]

  • Version 0

    Current

    Pues es solo hacer un round_down, funciona para negativos y positivos como muestro a continuacion

    package com.alliensoft.workflow.testclasses;

    import java.math.BigDecimal; import java.text.DecimalFormat; import java.text.NumberFormat; import java.util.Hashtable;

    /* * Date 9/03/2010.10:38:01 *

    pruebas de bigDecimal * @author pescamilla

    / public class TestTest {

    /**
     * Date 9/03/2010.10:38:01
     * @author pescamilla
     * @throws Exception Cualquier error ejecutando el constructor de cualquier prueba
     */
    public TestTest() throws Exception {
        int decimalPlaces = 2;
        BigDecimal bd = new BigDecimal("-123456789.0193456890");
        BigDecimal bd2 = new BigDecimal("123456789.0193456890");
        bd = bd.setScale(decimalPlaces, BigDecimal.ROUND_DOWN);
        bd2 = bd2.setScale(decimalPlaces, BigDecimal.ROUND_DOWN);
        System.out.println(bd.toString());
        System.out.println(bd2.toString());
    }
    
    /**
     * Date 9/03/2010.10:38:01
     * <p>Clase main
     * @author pescamilla
     * @param args argumentos no necesarios
     */
    public static void main(String[] args) {
        try {
            new TestTest();
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    
    }
    

    }

    By: David Cuadrado [ Admin ]

or Back