Initial commit
This commit is contained in:
@ -0,0 +1,30 @@
|
||||
// For more tutorials: https://blog.learngoprogramming.com
|
||||
//
|
||||
// Copyright © 2018 Inanc Gumus
|
||||
// Learn Go Programming Course
|
||||
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
||||
//
|
||||
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
fmt.Println("sum :", 3+2) // sum - int
|
||||
fmt.Println("sum :", 2+3.5) // sum - float64
|
||||
fmt.Println("dif :", 3-1) // difference - int
|
||||
fmt.Println("dif :", 3-0.5) // difference - float64
|
||||
fmt.Println("prod:", 4*5) // product - int
|
||||
fmt.Println("prod:", 5*2.5) // product - float64
|
||||
fmt.Println("quot:", 8/2) // quotient - int
|
||||
fmt.Println("quot:", 8/1.5) // quotient - float64
|
||||
|
||||
// remainder is only for integers
|
||||
fmt.Println("rem :", 8%3)
|
||||
// fmt.Println("rem:", 8.0%3) // error
|
||||
|
||||
// you can do this
|
||||
// since the fractional part of a float is zero
|
||||
f := 8.0
|
||||
fmt.Println("rem :", int(f)%3)
|
||||
}
|
Reference in New Issue
Block a user