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.
-2.514 -2.5139999389648438 -5.027999938964843
- How to convert Int data type to Float in Golang?
- Converting a string variable into Boolean, Integer or Float type in Golang
- How to Convert string to integer type in Golang?
- Different Ways to Convert the Boolean Type in String in Golang
- Type Casting or Type Conversion in Golang
- Searching an element of string type in Golang slice
- Finding Complementary Error Function of Float in Golang
- reflect.Float() Function in Golang with Examples
- How to convert a string in uppercase in Golang?
- How to convert a string in lower case in Golang?
- How to Convert a zero terminated byte array to string in Golang?
- Different Ways to Convert an Integer Variable to String in Golang
- How to add a method to struct type in Golang?
- Searching an element of float64 type in Golang slice
- Golang | Searching an element of int type in slice of ints
- Type Switches in GoLang
- How to Get Float64 Type Random Number in Golang?
- How to Get Float32 Type Random Number in Golang?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.