scale Float - Java java.lang

Java examples for java.lang:double

Description

scale Float

Demo Code


//package com.java2s;
import java.math.BigDecimal;

public class Main {
    public static float scaleFloat(float floatValue, int scale) {
        return scaleFloat(floatValue, scale, BigDecimal.ROUND_HALF_UP);
    }//from ww  w  .  j ava  2  s .  c  o  m

    public static float scaleFloat(float floatValue, int scale,
            int roundingMode) {
        return new BigDecimal(floatValue).setScale(scale, roundingMode)
                .floatValue();
    }
}

Related Tutorials