Java tutorial
//package com.java2s; //License from project: Open Source License public class Main { public static double roundFraction(Double value, int precision) { int scale = (int) Math.pow(10, precision); return (double) Math.round(value * scale) / scale; } }