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
+6.5k Golang : Selection sort example
+11.5k Golang : How to use if, eq and print properly in html template
+7.1k Golang : Find the shortest line of text example
+9.5k Golang : How to control fmt or log print format?
+8.5k Golang : Configure Apache and NGINX to access your Go service example
+12.5k Golang : Simple client-server HMAC authentication without SSL example
+6.3k Fix ERROR 2003 (HY000): Can't connect to MySQL server on 'IP address' (111)
+15.4k Golang : Save(pipe) HTTP response into a file
+5k Facebook : How to place save to Facebook button on your website
+13k Android Studio : Highlight ImageButton when pressed on example
+9.7k Javascript : Read/parse JSON data from HTTP response
+13.3k Golang : Convert(cast) int to int64