Documentation ¶
Overview ¶
Package checked implements basic arithmetic operations with underflow and overflow checks.
Index ¶
- Variables
- func AddInt32(a, b int32) (sum int32, ok bool)
- func AddInt64(a, b int64) (sum int64, ok bool)
- func AddUint32(a, b uint32) (sum uint32, ok bool)
- func AddUint64(a, b uint64) (sum uint64, ok bool)
- func DivInt32(a, b int32) (quotient int32, ok bool)
- func DivInt64(a, b int64) (quotient int64, ok bool)
- func DivUint32(a, b uint32) (quotient uint32, ok bool)
- func DivUint64(a, b uint64) (quotient uint64, ok bool)
- func LshiftInt32(a, b int32) (result int32, ok bool)
- func LshiftInt64(a, b int64) (result int64, ok bool)
- func LshiftUint32(a, b uint32) (result uint32, ok bool)
- func LshiftUint64(a, b uint64) (result uint64, ok bool)
- func ModInt32(a, b int32) (remainder int32, ok bool)
- func ModInt64(a, b int64) (remainder int64, ok bool)
- func ModUint32(a, b uint32) (remainder uint32, ok bool)
- func ModUint64(a, b uint64) (remainder uint64, ok bool)
- func MulInt32(a, b int32) (product int32, ok bool)
- func MulInt64(a, b int64) (product int64, ok bool)
- func MulUint32(a, b uint32) (product uint32, ok bool)
- func MulUint64(a, b uint64) (product uint64, ok bool)
- func NegateInt32(a int32) (negated int32, ok bool)
- func NegateInt64(a int64) (negated int64, ok bool)
- func SubInt32(a, b int32) (diff int32, ok bool)
- func SubInt64(a, b int64) (diff int64, ok bool)
- func SubUint32(a, b uint32) (diff uint32, ok bool)
- func SubUint64(a, b uint64) (diff uint64, ok bool)
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrOverflow = errors.New("arithmetic overflow")
Functions ¶
func LshiftInt32 ¶
LshiftInt32 returns a << b with an integer overflow check.
func LshiftInt64 ¶
LshiftInt64 returns a << b with an integer overflow check.
func LshiftUint32 ¶
LshiftUint32 returns a << b with an integer overflow check.
func LshiftUint64 ¶
LshiftUint64 returns a << b with an integer overflow check.
func NegateInt32 ¶
NegateInt32 returns -a with an integer overflow check.
func NegateInt64 ¶
NegateInt64 returns -a with an integer overflow check.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.