Example usage for java.math BigDecimal BigDecimal

List of usage examples for java.math BigDecimal BigDecimal

Introduction

In this page you can find the example usage for java.math BigDecimal BigDecimal.

Prototype

public BigDecimal(long val) 

Source Link

Document

Translates a long into a BigDecimal .

Usage

From source file:Main.java

public static String kgToLB_ForFatScale(float paramFloat) {
    BigDecimal localBigDecimal1 = new BigDecimal(String.valueOf(paramFloat));
    BigDecimal localBigDecimal2 = new BigDecimal("1155845");
    BigDecimal localBigDecimal3 = new BigDecimal("16");
    BigDecimal localBigDecimal4 = new BigDecimal("65536");
    BigDecimal localBigDecimal5 = new BigDecimal("2");
    return String
            .valueOf(new BigDecimal(String.valueOf(localBigDecimal1.multiply(localBigDecimal2).doubleValue()))
                    .divide(localBigDecimal3, 5, 6).divide(localBigDecimal4, 1, 4).multiply(localBigDecimal5)
                    .floatValue());/*from  ww w  .j  av  a 2s . c o m*/
}

From source file:Main.java

public static double changep2(double i) {
    // TODO Auto-generated method stub
    BigDecimal b = new BigDecimal(i);
    int saveBitNum = 2;
    double c = b.setScale(saveBitNum, BigDecimal.ROUND_HALF_UP).doubleValue();
    return c;/*w  w  w  .  j a va 2  s.co m*/
}

From source file:Main.java

public static double kgToLB_ForFatScale2(double paramDouble) {
    BigDecimal localBigDecimal1 = new BigDecimal(String.valueOf(paramDouble));
    BigDecimal localBigDecimal2 = new BigDecimal("1155845");
    BigDecimal localBigDecimal3 = new BigDecimal("16");
    BigDecimal localBigDecimal4 = new BigDecimal("65536");
    BigDecimal localBigDecimal5 = new BigDecimal("2");
    return new BigDecimal(String.valueOf(localBigDecimal1.multiply(localBigDecimal2).doubleValue()))
            .divide(localBigDecimal3, 5, 6).divide(localBigDecimal4, 1, 4).multiply(localBigDecimal5)
            .doubleValue();// w ww .j  av a2  s  .  c  o m
}

From source file:Main.java

public static String conversionDistanse(int aDistanceMeter) {
    return (aDistanceMeter >= 1000) ? Math.round((new BigDecimal(String.valueOf(aDistanceMeter / 1000))
            .setScale(1, BigDecimal.ROUND_HALF_UP).longValue())) + "km" : aDistanceMeter + "m";
}

From source file:Main.java

public static int convertsToInt(double v) {
    BigDecimal b = new BigDecimal(v);
    return b.intValue();
}

From source file:Main.java

public static Float getDoubleFromDoubletRoundHalfUp(double sourceNum, int scale) {
    BigDecimal bigDecimal = new BigDecimal(sourceNum);
    return bigDecimal.setScale(scale, BigDecimal.ROUND_HALF_UP).floatValue();
}

From source file:Main.java

public static long convertsToLong(double v) {
    BigDecimal b = new BigDecimal(v);
    return b.longValue();
}

From source file:Main.java

public static Double getDoubleFromDoubletRoundHalfUp1(double sourceNum, int scale) {
    BigDecimal bigDecimal = new BigDecimal(sourceNum);
    return bigDecimal.setScale(scale, BigDecimal.ROUND_HALF_UP).doubleValue();
}

From source file:Main.java

public static String setThousandSeparator(long number) {
    BigDecimal bd = new BigDecimal(number);
    NumberFormat formatter = NumberFormat.getInstance();
    return formatter.format(bd.longValue());
}

From source file:Main.java

public static double byteCastMB(long number) {
    double n = number / 1024.0 / 1024.0;
    BigDecimal bd = new BigDecimal(n);
    bd = bd.setScale(2, BigDecimal.ROUND_HALF_UP);
    return bd.doubleValue();
}