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
+6.9k Golang : Generate EAN barcode
+3.1k Golang : Get a list of crosses(instruments) available to trade from Oanda account
+25.5k Golang : Converting a negative number to positive number
+30k Golang : How to stream file to client(browser) or write to http.ResponseWriter?
+13k Golang : Read large file with bufio.Scanner cause token too long error
+20.3k Golang : convert rune to integer value
+4.1k Golang : Use NLP to get sentences for each paragraph example
+28k Golang : Example for ECDSA(Elliptic Curve Digital Signature Algorithm) package functions
+4.7k Grep : How to grep for strings inside binary data
+4.8k Default cipher that OpenSSL used to encrypt a PEM file
+23.5k Golang : Find files by name - cross platform example
+15.9k Golang : Padding data for encryption and un-padding data for decryption