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
+17.2k Google Chrome : Your connection to website is encrypted with obsolete cryptography
+6.1k Fix ERROR 2003 (HY000): Can't connect to MySQL server on 'IP address' (111)
+8.3k Your page has meta tags in the body instead of the head
+30.3k Golang : How to verify uploaded file is image or allowed file types
+13.6k Android Studio : Password input and reveal password example
+13.8k Golang : convert(cast) string to float value
+40.4k Golang : Convert to io.ReadSeeker type
+13.6k Golang : Get user input until a command or receive a word to stop
+17.5k Golang : Find smallest number in array
+7.4k Linux : How to fix Brother HL-1110 printing blank page problem
+16.3k Golang : convert string or integer to big.Int type
+4.1k Javascript : Empty an array example