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
+11.4k Golang : Generate DSA private, public key and PEM files example
+17.4k Golang : Clone with pointer and modify value
+8.7k Golang : Take screen shot of browser with JQuery example
+20k Swift : Convert (cast) Int to int32 or Uint32
+18.2k Golang : How to get hour, minute, second from time?
+8.1k Golang : Configure Apache and NGINX to access your Go service example
+19.8k Golang : Convert(cast) bytes.Buffer or bytes.NewBuffer type to io.Reader
+36.3k Golang : Validate IP address
+14.4k Golang : Rename directory
+8.7k Golang : Find network service name from given port and protocol
+9.4k Golang : Extract or copy items from map based on value
+18.3k Golang : Logging with logrus