Golang : convert(cast) string to float value
To convert or cast a string to float value, just use the strconv.ParseFloat()
function. Below is the code example to demonstrate how to convert string to float64 value.
package main
import (
"fmt"
"strconv"
)
func main() {
var floatvalue float64
floatvalue, _ = strconv.ParseFloat("123.456", 64)
fmt.Println(floatvalue)
}
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.3k Javascript : Change page title to get viewer attention
+12.8k Golang : How to check if your program is running in a terminal
+18.5k Golang : How to get time from unix nano example
+6.8k Swift : Convert (cast) String to Double
+7.1k Golang : Auto-generate reply email with text/template package
+7.1k Golang : Reverse text lines or flip line order example
+12.1k Golang : Read from buffered reader until specific number of bytes
+12.4k Golang : Query string with space symbol %20 in between
+22.7k Golang : Upload to S3 with official aws-sdk-go package
+9.7k PHP : Convert(cast) bigInt to string
+7k Golang : Tell color name with OpenCV example
+5.1k Golang : Convert Chinese UTF8 characters to Pin Yin