logo-MindMajix
PostGoLangGoLang
J
James ROBERT

Posted on 12th June 2024|122 views

0
votes

Golang Convert Int To Float64

How to convert int type to float64 in Golang?

1 answers
Answers
P
Sowjanya Kodiganti

Posted on 12th June 2024| views

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
Name
Course *
Email *
Phone Number