Java tutorial
//package com.java2s; import java.math.BigDecimal; public class Main { public static float GetVoltage(int rawVal) { return precision(2, rawVal * 0.01955f); } private static Float precision(int decimalPlace, Float d) { BigDecimal bd = new BigDecimal(Float.toString(d)); bd = bd.setScale(decimalPlace, BigDecimal.ROUND_HALF_UP); return bd.floatValue(); } }