Post

GoLangGoLang

J
James ROBERT

Posted on 25th April 2024|119 views

0
votes

Golang Convert Int To Float64

How to convert int type to float64 in Golang?

Answers
P
Sowjanya Kodiganti

Posted on 25th April 2024

package main

  import (

    "fmt"

    "reflect"

)

  func main() {

  var p int64 = 6

var q float64 = float64(p)

 fmt.Printf("p = %d \n", p)

    fmt.Printf("q = %f \n", q)

  fmt.Printf("\ny upto 3 decimal = %.3f", q)

  fmt.Println("\n", reflect.TypeOf(q))}

 

Write your answer

STILL GOT QUERIES?

Get a Live FREE Demo
  • Explore the trending and niche courses and learning maps
  • Learn about tuition fee, payment plans, and scholarships
  • Get access to webinars and self-paced learning videos