Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!
System.out.printf¶
System.out.printf("Pi: %.2f", 3.1415926)Pi: 3.14java.io.PrintStream@510906c3String.format¶
String.format("%1.2f", 3.1415926)3.14"%1.2f".format(3.1415926)3.14java.text.DecimalFormat¶
import java.text.DecimalFormat
DecimalFormat("#.##").format(3.1415926)3.14kotlin.math.round¶
kotlin.math.round(3.1415926)3.0kotlin.math.round(3.1415926 * 100) / 100.03.14%classpath add mvn org.apache.commons commons-math3 3.6.1Loading...
Loading...
import org.apache.commons.math3.util.Precision
Precision.round(3.1415926, 2)3.14