How to Convert string to float type in Golang? Last Updated : 19 May, 2020 Comments Improve Suggest changes Like Article Like Report ParseFloat function is an in-build function in the strconv library which converts the string type into a floating-point number with the precision specified by bit size. Example: In this example the same string -2.514 is being converted into float data type and then their sum is being printed. Once it is converted to 8 bit-size and other times it is 32 bit-size. Both yield different results because ParseFloat accepts decimal and hexadecimal floating-point number syntax. If a1 or a2 is well-formed and near a valid floating-point number, ParseFloat returns the nearest floating-point number rounded using IEEE754 unbiased rounding which is parsing a hexadecimal floating-point value only rounds when there are more bits in the hexadecimal representation than will fit in the mantissa. C // Golang program to Convert // string to float type package main import ( "fmt" "strconv" ) func main() { // defining a string a1 a1 := "-2.514" // converting the string a1 // into float and storing it // in b1 using ParseFloat b1, _ := strconv.ParseFloat(a1, 8) // printing the float b1 fmt.Println(b1) a2 := "-2.514" b2, _ := strconv.ParseFloat(a2, 32) fmt.Println(b2) fmt.Println(b1 + b2) } Output: -2.514 -2.5139999389648438 -5.027999938964843 Comment More infoAdvertise with us Next Article How to Convert string to float type in Golang? P pcpiyush1106 Follow Improve Article Tags : Go Language Write From Home Golang-strconv Golang-Program Similar Reads How to convert Int data type to Float in Golang? In Golang, the data types are bound to variables rather than the values, which means that, if you declare a variable as int, then you can store only integer type value in it, you cant assign character or string in it unless you convert the data type to required data type. To convert an integer data 2 min read How to Convert string to integer type in Golang? Strings in Golang is a sequence of variable-width characters where each and every character is represented by one or more bytes using UTF-8 Encoding. In Go language, both signed and unsigned integers are available in four different sizes. In order to convert string to integer type in Golang, you can 2 min read How to convert String to Float in PHP ? Converting a string to a float in PHP is a common requirement when handling numeric data stored in string format. This conversion allows the numeric string to be used in calculations or comparisons, ensuring accurate manipulation of data within the program.There are many methods to convert a string 3 min read How to Trim a String in Golang? In Go, strings are UTF-8 encoded sequences of variable-width characters, unlike some other languages like Java, python and C++. Go provides several functions within the strings package to trim characters from strings.In this article we will learn how to Trim a String in Golang.Examples := "@@Hello, 2 min read Different Ways to Convert the Boolean Type in String in Golang In order to convert Boolean Type to String type in Golang , you can use the strconv and fmt package function. 1. strconv.FormatBool() Method: The FormatBool is used to Boolean Type to String. It returns "true" or "false" according to the value of b. Syntax: func FormatBool(b bool) string Example : C 2 min read Like