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
+8.2k Golang : Temperatures conversion example
+7k Swift : Convert (cast) String to Float
+5.5k Golang : Find the longest line of text example
+3.9k Javascript : How to get width and height of a div?
+23.2k Golang : GORM read from database example
+13.4k Golang : package is not in GOROOT during compilation
+20.4k Golang : Use TLS version 1.2 and enforce server security configuration over client
+9.9k Golang : Characters limiter example
+4.8k PHP : Get client IP address
+7k Golang : Append and add item in slice
+3.5k Golang : Valued expressions and functions example
+6.9k Golang : Gomobile init produce "iphoneos" cannot be located error