+ 1

Please help me with one thing, can you please tell me how to make Kotlin always output a fraction?

I need to make sure that the output data must be of the Double type, even if the sum is a round number, please help. 🙏🙏🙏

20th Jun 2021, 6:37 PM
Fig∆zz
Fig∆zz - avatar
6 Answers
+ 4
If you wish to force decimal points to 2, you can use: print("%.2d".format(sum.toDouble()))
25th Jun 2021, 5:43 PM
John Wells
John Wells - avatar
+ 1
FigAzz would you please post your question in English, So We can help you.
20th Jun 2021, 6:55 PM
JRAMAHES
JRAMAHES - avatar
+ 1
Okay, l translating with interpreter
20th Jun 2021, 8:07 PM
Fig∆zz
Fig∆zz - avatar
+ 1
print(sum.toDouble())
20th Jun 2021, 9:26 PM
visph
visph - avatar
+ 1
Thank you very much 😃😁🙃
21st Jun 2021, 8:23 AM
Fig∆zz
Fig∆zz - avatar
+ 1
If you wish to force decimal points to 2, you can use: print("%.2d".format(sum.toDouble())) Thank you
25th Jun 2021, 8:44 PM
Fig∆zz
Fig∆zz - avatar