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
+3.1k Detect if Google Analytics and Developer Media are loaded properly or not
+31.3k Golang : Smarter Error Handling with strings.Contains()
+4.8k Golang : Struct field tags and what is their purpose?
+7.7k nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
+14k Golang : rune literal not terminated error
+10.5k Golang : Convert decimal number(integer) to IPv4 address
+4.8k Cash Flow : 50 days to pay your credit card debt
+16k Golang : delete and modify XML file content
+7.9k Golang : Take screen shot of browser with JQuery example
+3.3k Golang : Converting individual Jawi alphabet to Rumi(Romanized) alphabet example
+10.9k Golang : List running EC2 instances and descriptions
+7.6k Golang : Sort lines of text example