Menu Close

Go – Program to check the floating-point variable contains zero value or not in go

Here, we will see program to check the floating-point variable contains zero value or not in go. We will also see how to use it in program with example.

Zero value of floating-point variable in go is 0.0.

Code:

package main

import (

  "fmt"

)

func main() {

  var n float32 = 0.0

  if n == 0.0 {

    fmt.Println("Contains zero value: ", n)

  } else {

    fmt.Println("Does not contains zero value: ", n)

  }
}

Output:

Contains zero value: 0

To learn more about golang. Please follow given below link.

https://www.techieindoor.com/go-lang/

References:

https://golang.org/doc/
https://golang.org/pkg/

Posted in golang, golang program

Leave a Reply

Your email address will not be published.