91 lines
1 KiB
Go
91 lines
1 KiB
Go
package main
|
|
|
|
import "fmt"
|
|
|
|
func nothing() {
|
|
|
|
}
|
|
|
|
func voidS8Bit() int8 {
|
|
return 77
|
|
}
|
|
|
|
func voidS16Bit() int16 {
|
|
return 100
|
|
}
|
|
|
|
func voidS32Bit() int32 {
|
|
return 200
|
|
}
|
|
|
|
func voidS64Bit() int64 {
|
|
return 300
|
|
}
|
|
|
|
func voidU8Bit() uint8 {
|
|
return 77
|
|
}
|
|
|
|
func voidU16Bit() uint16 {
|
|
return 100
|
|
}
|
|
|
|
func voidU32Bit() uint32 {
|
|
return 200
|
|
}
|
|
|
|
func voidU64Bit() uint64 {
|
|
return 300
|
|
}
|
|
|
|
func voidS8Pair() (int8, int8) {
|
|
return -100, 100
|
|
}
|
|
|
|
func voidS16Pair() (int16, int16) {
|
|
return -1000, 1000
|
|
}
|
|
|
|
func neg8(a int8) int8 {
|
|
return -a
|
|
}
|
|
|
|
func neg16(a int16) int16 {
|
|
return -a
|
|
}
|
|
|
|
func sum16(a int16, b int16) int32 {
|
|
return (int32)(a + b)
|
|
}
|
|
|
|
func main() {
|
|
nothing()
|
|
|
|
// Signed integers
|
|
s8 := voidS8Bit()
|
|
s16 := voidS16Bit()
|
|
s32 := voidS32Bit()
|
|
s64 := voidS64Bit()
|
|
|
|
fmt.Println(s8, s16, s32, s64)
|
|
|
|
//Unsigned integers
|
|
voidU8Bit()
|
|
voidU16Bit()
|
|
voidU32Bit()
|
|
voidU64Bit()
|
|
|
|
//One argument function
|
|
a8 := neg8(1)
|
|
b8 := neg8(-1)
|
|
|
|
//Return pairs
|
|
a8, b8 = voidS8Pair()
|
|
neg8(a8)
|
|
neg8(b8)
|
|
|
|
a16, b16 := voidS16Pair()
|
|
neg16(a16)
|
|
neg16(b16)
|
|
sum16(a16, b16)
|
|
}
|