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
+7.2k Golang : How to get garbage collection data?
+7.8k Android Studio : Checkbox for user to select options example
+16.8k Golang : Delete duplicate items from a slice/array
+35.5k Golang : UDP client server read write example
+16.7k Golang : Close channel after ticker stopped example
+8.1k Golang : Get UDP client IP address and differentiate clients by port number
+18.6k Golang : Match strings by wildcard patterns with filepath.Match() function
+2.9k Linux : How to set root password in Linux Mint
+11.2k Golang : Get uploaded file name or access uploaded files
+7.2k Golang : does not implement flag.Value (missing Set method)
+69.6k Golang : How to convert character to ASCII and back
+6.3k Golang : How to get username from email address