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
+4.3k Javascript : Detect when console is activated and do something about it
+40.7k Golang : How to check if a string contains another sub-string?
+12.6k Golang : Convert IPv4 address to packed 32-bit binary format
+19.4k Golang : Set or Add HTTP Request Headers
+10.9k Google Maps URL parameters configuration
+34.2k Golang : How to stream file to client(browser) or write to http.ResponseWriter?
+9.8k Golang : Edge detection with Sobel method
+12.9k Golang : Convert(cast) int to int64
+7.4k Golang : Mapping Iban to Dunging alphabets
+16.2k Golang : Delete files by extension
+22.8k Golang : Randomly pick an item from a slice/array example
+8.8k Golang : Handle sub domain with Gin