Is there a function that can truncate or round a Double? At one point in my code I would like a number like: 1.23456789 to be rounded to 1.23
1.23456789
1.23
How about :
val value = 1.4142135623730951 //3 decimal places println((value * 1000).round / 1000.toDouble) //4 decimal places println((value * 10000).round / 10000.toDouble)