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
+8.8k Swift : Convert (cast) Float to String
+4.6k Golang : Calculate how many weeks left to go in a given year
+3.2k Java : Human readable password generator
+7.2k Golang : Edge detection with Sobel method
+6.3k Golang : Ordinal and Ordinalize a given number to the English ordinal numeral
+8.6k Golang : Clean formatting/indenting or pretty print JSON result
+5.8k Swift : Convert (cast) String to Double
+3.1k Javascript : Change page title to get viewer attention
+9.4k Golang : Extract part of string with regular expression
+3k Linux/MacOSX : How to symlink a file?
+4.6k Javascript : Push notifications to browser with Push.js
+12k Golang : convert string or integer to big.Int type