Golang : convert(cast) float to string
This is an add-on to this previous tutorial on converting/casting int to string. To convert or cast a float value to string, just use the strconv.FormatFloat function.
package main
import "fmt"
import "strconv"
func main() {
str := strconv.FormatFloat(12342323.234232, 'f', 6, 64)
fmt.Println(str)
}
Reference :
By Adam Ng
IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.
Advertisement
Tutorials
+17.7k Unmarshal/Load CSV record into struct in Go
+32.8k Golang : Create x509 certificate, private and public keys
+14.1k Golang : How to check if IP address is in range
+7.3k Golang : Emulate NumPy way of creating matrix example
+13.3k Golang : Convert IP version 6 address to integer or decimal number
+8k Golang : GMail API create and send draft with simple upload attachment example
+8.5k Golang : How to get ECDSA curve and parameters data?
+6.3k Golang : Transform lisp or spinal case to Pascal case example
+9.6k Golang : Allow Cross-Origin Resource Sharing request
+9k Golang : Identifying Golang HTTP client request
+2.3k Golang : Fix go-cron set time not working issue
+16.6k Golang : [json: cannot unmarshal object into Go value of type]