
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Convert Int Data Type to Float in Golang
In Golang, it is easy to convert one data type to another using type conversion. In this tutorial, we will explore how to convert an integer to a float data type.
Converting Int to Float
In Golang, converting an integer to a float is a straightforward process. You can use the float64() function to convert an integer to a float data type.
Example
Here is an example ?
package main import "fmt" func main() { i := 5 f := float64(i) fmt.Println("The integer value is: ", i) fmt.Println("The float value is: ", f) }
Output
The integer value is: 5 The float value is: 5
In the above example, we have an integer value of 5. We are using the float64() function to convert this integer value to a float data type. The float value is then assigned to a variable 'f'.
Conclusion
In conclusion, we have learned how to convert an integer to a float data type in Golang. The process is very straightforward, and all you need is to use the float64() function to perform the conversion.
Advertisements