Java tutorial
//package com.java2s; public class Main { public static float scaleNumber(float num, int bit) { int range = 10 * bit; return (float) Math.round(num * range) / range; } }