How to add zero after a decimal point in float datatype

Skip to first unread message

pravin chaudhary

unread,
Oct 12, 2022, 3:31:37 PM10/12/22
to golang-nuts
I need to add zero after a decimal point to a float datatype but not able to do.

Required float value = 5.00 but getting as 5

Datatype should be float only!!

Any help will be much appreciated!

Thanks,
Pravin

Jan Mercl

unread,
Oct 12, 2022, 3:50:25 PM10/12/22
to pravin chaudhary, golang-nuts
Is this perhaps what you're looking for? https://go.dev/play/p/LnaYYA_8VOg

Joshua Christudoss

unread,
Oct 12, 2022, 6:22:38 PM10/12/22
to Jan Mercl, pravin chaudhary, golang-nuts
Use  
%.2f     in   fmt.printf


Thanks & Regards

Joshua Christudoss
In Christ | For Christ | By Christ


Sent from Yahoo Mail on Android



--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsub...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAA40n-WV%2BD3QCa6q%3DcUNi338-cZTBkNyUpbODHxVYZL%2BiG2G_A%40mail.gmail.com.

Reply all
Reply to author
Forward
0 new messages