Initial commit

This commit is contained in:
Inanc Gumus
2018-10-13 23:30:21 +03:00
commit cde4e6632c
567 changed files with 17896 additions and 0 deletions

View File

@@ -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)
}

View File

@@ -0,0 +1,33 @@
// 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() {
// what's the value of the ratio?
// 3 / 2 = 1.5?
var ratio float64 = 3 / 2
fmt.Println(ratio)
// explain
// above expression equals to this:
ratio = float64(int(3) / int(2))
fmt.Println(ratio)
// how to fix it?
//
// remember, when one of the values is a float value
// the result becomes a float
ratio = float64(3) / 2
fmt.Println(ratio)
// or
ratio = 3.0 / 2
fmt.Println(ratio)
}