How To Round Double To 2 Digit Decimals

[Solved] How To Round Double To 2 Digit Decimals | Perl - Code Explorer | yomemimo.com
Question : how to round Double to 2 digit decimals

Answered by : evil-eel-gmvw0c4gxozy

import java.math.BigDecimal
import java.math.RoundingMode
val decimal = BigDecimal(3.14159265359).setScale(2, RoundingMode.HALF_EVEN)
println(decimal) // 3.14

Source : https://discuss.kotlinlang.org/t/how-do-you-round-a-number-to-n-decimal-places/8843/3 | Last Update : Wed, 20 Oct 21

Answers related to how to round double to 2 digit decimals

Code Explorer Popular Question For Perl