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
+9.6k Golang : Get local time and equivalent time in different time zone
+6.5k Golang : Getting Echo framework StartAutoTLS to work
+20k Golang : How to get time zone and load different time zone?
+7.6k Golang : Progress bar with ∎ character
+22.2k Golang : Fix type interface{} has no field or no methods and type assertions example
+4.3k JavaScript/JQuery : Redirect page examples
+8.9k Golang : Get current, epoch time and display by year, month and day
+25.6k PHP : Convert(cast) string to bigInt
+18.1k Golang : How to get own program name during runtime ?
+15.7k Golang : Get input from keyboard
+11.1k Android Studio : Highlight ImageButton when pressed on example
+21.7k Golang : Calculate time different