Saturday, 19 September 2020

golang2

//tutorial.go
 package main

import "fmt"

func main() {
price := 12.3
fmt.Printf("value is %v, type is %t\n\n", price, price)
decimal := 1025
fmt.Printf("%b\n", decimal)
fmt.Printf("%c\n", decimal)
fmt.Printf("%d\n", decimal)
fmt.Printf("%o\n", decimal)
fmt.Printf("%q\n", decimal)
fmt.Printf("%x\n\n", decimal)
number := 12345.6789
fmt.Printf("%e\n", number)
fmt.Printf("%.2f\n", number)
fmt.Printf("%15.2f\n", number)

}

//cmd
C:\Users\bob\golang1>go run tutorial.go
value is 12.3, type is %!t(float64=12.3)

10000000001
Ё
1025
2001
'Ё'
401

1.234568e+04
12345.68
       12345.68

reference:

No comments:

Post a Comment