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
+5k Nginx and PageSpeed build from source CentOS example
+6.4k PHP : Proper way to get UTF-8 character or string length
+6k AWS S3 : Prevent Hotlinking policy
+7.9k Golang : Load DSA public key from file example
+9.6k Golang : Extract or copy items from map based on value
+12.2k Golang : Save webcamera frames to video file
+11.1k Golang : Generate random elements without repetition or duplicate
+23k Golang : Calculate time different
+5.6k PHP : Fix Call to undefined function curl_init() error
+6.1k Golang : How to verify input is rune?
+18.1k Golang : How to log each HTTP request to your web server?
+40.7k Golang : Convert to io.ReadSeeker type