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
+17.4k Golang : Linked list example
+10.6k Golang : Simple File Server
+10.3k Golang : Simple Jawi(Yawi) to Rumi(Latin/Romanize) converter
+11.1k CodeIgniter : How to check if a session exist in PHP?
+4.9k Nginx and PageSpeed build from source CentOS example
+9.3k Golang : Terminate-stay-resident or daemonize your program?
+7.4k Golang : Get YouTube playlist
+6.1k Golang : Get Hokkien(福建话)/Min-nan(閩南語) Pronounciations
+5.7k CodeIgniter/PHP : Remove empty lines above RSS or ATOM xml tag
+6.3k CodeIgniter : form input set_value cause " to become & quot
+4.3k Golang : Valued expressions and functions example
+24k Golang : Find biggest/largest number in array