How to print float value in golang?

Hi Friends 👋,

Welcome To aGuideHub! ❤️

Today, I’m going to show you how to print float value in the golang console, here we will use the fmt package to print value.

When we going to print float variable value, we have to pass %f in the Printf() method or we also can use the fmt.Print() method without passing %f.

Let’s write code.

package main
import "fmt"

func main() {
	fmt.Printf("%f\n", 23.65)
	fmt.Print(23.65)
}

When we run the above code, you should show your float value in the golang console like the below image.

print, float, golang

Try it yourself

All the best 👍

Premium Content

You can get all the below premium content directly in your mail when you subscribe us

Books

Portfolio Template

View | Get Source Code

Cheat Sheets

Cheat Sheets Books are basically Important useful notes which we use in our day-to-day life.

I'm working on some more Cheat Sheets book on Jquery, TypeScript, React js and for other languages. I will send it once it's completed.

Stay tuned working on React Js Cheat Sheets Book

Related Posts