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
+9.5k Golang : How to transmit update file to client by HTTP request example
+17.3k Golang : Example for RSA package functions
+18.9k Nginx + FastCGI + Go Setup.
+10.5k Golang : Get remaining text such as id or filename after last segment in URL path
+15.8k Golang : XML to JSON example
+11.1k Golang : Forwarding a local port to a remote server example
+13k Golang : Send email with attachment(RFC2822) using Gmail API example
+37.9k Golang : How to iterate over a []string(array)
+8.4k Facebook : Getting the friends list with PHP return JSON format
+5.9k Golang : How to call function inside template with template.FuncMap
+18.4k Swift : Convert (cast) Int to int32 or Uint32
+4.2k Golang : Constant and variable names in native language