checked

package
v0.0.0-...-c7fad54 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 1, 2024 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package checked implements basic arithmetic operations with underflow and overflow checks.

Index

Constants

This section is empty.

Variables

View Source
var ErrOverflow = errors.New("arithmetic overflow")

Functions

func AddInt32

func AddInt32(a, b int32) (sum int32, ok bool)

AddInt32 returns a + b with an integer overflow check.

func AddInt64

func AddInt64(a, b int64) (sum int64, ok bool)

AddInt64 returns a + b with an integer overflow check.

func AddUint32

func AddUint32(a, b uint32) (sum uint32, ok bool)

AddUint32 returns a + b with an integer overflow check.

func AddUint64

func AddUint64(a, b uint64) (sum uint64, ok bool)

AddUint64 returns a + b with an integer overflow check.

func DivInt32

func DivInt32(a, b int32) (quotient int32, ok bool)

DivInt32 returns a / b with an integer overflow check.

func DivInt64

func DivInt64(a, b int64) (quotient int64, ok bool)

DivInt64 returns a / b with an integer overflow check.

func DivUint32

func DivUint32(a, b uint32) (quotient uint32, ok bool)

DivUint32 returns a / b with an integer overflow check.

func DivUint64

func DivUint64(a, b uint64) (quotient uint64, ok bool)

DivUint64 returns a / b with an integer overflow check.

func LshiftInt32

func LshiftInt32(a, b int32) (result int32, ok bool)

LshiftInt32 returns a << b with an integer overflow check.

func LshiftInt64

func LshiftInt64(a, b int64) (result int64, ok bool)

LshiftInt64 returns a << b with an integer overflow check.

func LshiftUint32

func LshiftUint32(a, b uint32) (result uint32, ok bool)

LshiftUint32 returns a << b with an integer overflow check.

func LshiftUint64

func LshiftUint64(a, b uint64) (result uint64, ok bool)

LshiftUint64 returns a << b with an integer overflow check.

func ModInt32

func ModInt32(a, b int32) (remainder int32, ok bool)

ModInt32 returns a % b with an integer overflow check.

func ModInt64

func ModInt64(a, b int64) (remainder int64, ok bool)

ModInt64 returns a % b with an integer overflow check.

func ModUint32

func ModUint32(a, b uint32) (remainder uint32, ok bool)

ModUint32 returns a % b with an integer overflow check.

func ModUint64

func ModUint64(a, b uint64) (remainder uint64, ok bool)

ModUint64 returns a % b with an integer overflow check.

func MulInt32

func MulInt32(a, b int32) (product int32, ok bool)

MulInt32 returns a * b with an integer overflow check.

func MulInt64

func MulInt64(a, b int64) (product int64, ok bool)

MulInt64 returns a * b with an integer overflow check.

func MulUint32

func MulUint32(a, b uint32) (product uint32, ok bool)

MulUint32 returns a * b with an integer overflow check.

func MulUint64

func MulUint64(a, b uint64) (product uint64, ok bool)

MulUint64 returns a * b with an integer overflow check.

func NegateInt32

func NegateInt32(a int32) (negated int32, ok bool)

NegateInt32 returns -a with an integer overflow check.

func NegateInt64

func NegateInt64(a int64) (negated int64, ok bool)

NegateInt64 returns -a with an integer overflow check.

func SubInt32

func SubInt32(a, b int32) (diff int32, ok bool)

SubInt32 returns a - b with an integer overflow check.

func SubInt64

func SubInt64(a, b int64) (diff int64, ok bool)

SubInt64 returns a - b with an integer overflow check.

func SubUint32

func SubUint32(a, b uint32) (diff uint32, ok bool)

SubUint32 returns a - b with an integer overflow check.

func SubUint64

func SubUint64(a, b uint64) (diff uint64, ok bool)

SubUint64 returns a - b with an integer overflow check.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL