How to include 0 after decimal | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to include 0 after decimal

val price = 32.50 println (price) result is 32.5 Desired result 32.50

28th Aug 2018, 11:11 AM
joey game
joey game - avatar
2 Answers
+ 8
In this case, you can round it off to two decimal places (#.##) val price = 32.50 println ("%.2f".format(price)) More information is given here: https://www.programiz.com/kotlin-programming/examples/round-number-decimal
28th Aug 2018, 11:21 AM
Dev
Dev - avatar
+ 1
thank you that worked. as an unemployed learner i couldn't be more grateful for the help provided by the solo community. thanks again
28th Aug 2018, 11:26 AM
joey game
joey game - avatar