Skip to content

Instantly share code, notes, and snippets.

@HORKimhab
Last active July 2, 2022 15:41
Show Gist options
  • Save HORKimhab/bbebcf901fc0f048385ca2400ed60e7b to your computer and use it in GitHub Desktop.
Save HORKimhab/bbebcf901fc0f048385ca2400ed60e7b to your computer and use it in GitHub Desktop.
package main
import "fmt"
func main() {
fmt.Println("Golang Float")
var x float32 = 123.78
var y float32 = 3.4e+38
var salary1 float32
var salary2 float64
salary1 = 50000.503882901
// can store decimals with greater precision
salary2 = 50000.503882901
a := 20.45
b := 34.89
// Subtraction of two
// floating-point number
c := b-a
fmt.Printf("Type: %T, value: %v\n", x, x)
fmt.Printf("Type: %T, value: %v\n", y, y)
fmt.Println(salary1)
fmt.Println(salary2)
// Display the result
fmt.Printf("Result is: %f", c)
// Display the type of c variable
fmt.Printf("\nThe type of c is : %T", c)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment