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.3k Golang : Gomobile init produce "iphoneos" cannot be located error
+4.3k Unix/Linux : Get reboot history or check when was the last reboot date
+11.4k Golang : How to determine if a year is leap year?
+16.6k Swift : Convert (cast) Int to int32 or Uint32
+7.2k Golang : Scramble and unscramble text message by randomly replacing words
+3.2k Golang : Get a list of crosses(instruments) available to trade from Oanda account
+11.6k Golang : Chunk split or divide a string into smaller chunk example
+7.2k Golang : Heap sort example
+9k Golang : GTK Input dialog box examples
+30.6k Golang : How to stream file to client(browser) or write to http.ResponseWriter?
+9.7k Swift : Convert (cast) Float to String
+14.6k Golang : Merge video(OpenCV) and audio(PortAudio) into a mp4 file