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.1k Golang : Check if a word is countable or not
+13.2k Golang : GUI with Qt and OpenCV to capture image from camera
+11.9k Golang : Handle or parse date string with Z suffix(RFC3339) example
+5.4k Golang : Convert an executable file into []byte example
+6.4k Golang : Hue, Saturation and Value(HSV) with OpenCV example
+5.8k Restart Apache or Nginx web server without password prompt
+18.3k Golang : How to Set or Add Header http.ResponseWriter?
+2.7k Java : Get FX sentiment from website example
+11.1k Golang : Add ASCII art to command line application launching process
+12.7k Golang : convert rune to unicode hexadecimal value and back to rune character
+39.2k Golang : How to count duplicate items in slice/array?