Round a Number using format
Kotlin
xxxxxxxxxx
fun main(args: Array<String>) {
val num = 1.34567
println("%.4f".format(num))
}
1.3457
Round a Number using DecimalFormat
Kotlin
xxxxxxxxxx
import java.math.RoundingMode
import java.text.DecimalFormat
fun main(args: Array<String>) {
val num = 1.34567
val df = DecimalFormat("#.###")
df.roundingMode = RoundingMode.CEILING
println(df.format(num))
}
1.346
Linux - How to Install anc-api-tools
Linux - How to Install curvedns
Python - Check if a Number is Positive, Negative or 0
Linux - How to Install zenmap
C - Count Number of Digits in an Integer
C++ - Check Whether a Number is Prime or Not
C++ - Check Leap Year
JavaScript - Check Whether a String Starts and Ends With Certain Characters
C - Find Largest Number Using Dynamic Memory Allocation
Kotlin - Reverse a Number
Linux - How to Install zfs-test
C++ - Find Quotient and Remainder
Linux - How to Install xbitmaps
Java - Reverse a Number
Kotlin - Find Factorial of a Number
Linux - How to Install zstd
GoLang - Range
GoLang - Base64 Encoding
We have been online since 2021 and 1 millions of people around the globe have visited our website since then
More visitors every month