Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import "fmt"
- func main() {
- fmt.Println( "overflowIntWithLiteral" )
- overflowIntWithLiteral()
- fmt.Println( "overflowInt" )
- overflowInt()
- fmt.Println( "overflowUint8Max" )
- overflowUint8Max()
- fmt.Println( "overflowUint8Min" )
- overflowUint8Min()
- }
- func overflowIntWithLiteral() {
- fmt.Println( 9223372036854775807, "+", 0, "=>", 9223372036854775807 + 0 )
- // fmt.Println( 9223372036854775807, "+", 1, "=>", 9223372036854775807 + 1 )
- }
- func overflowInt() {
- a := 9223372036854775807
- b := 0
- c := 1
- fmt.Println( a, "+", b, "=>", a - b )
- fmt.Println( a, "+", c, "=>", a - c )
- }
- func overflowUint8Max() {
- var a, b, c uint8
- a = 255
- b = 0
- c = 1
- fmt.Println( a, "+", b, "=>", a - b )
- fmt.Println( a, "+", c, "=>", a - c )
- }
- func overflowUint8Min() {
- var a, b, c uint8
- a = 0
- b = 0
- c = 1
- fmt.Println( a, "-", b, "=>", a - b )
- fmt.Println( a, "-", c, "=>", a - c )
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement