arith

package
v3.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2018 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package arith provides simple, primarily bit-specific, arithmetic operations.

Package pow implements basic power functions.

Index

Constants

View Source
const (
	// PowTabLen is the largest cached power for integers.
	PowTabLen = 20

	// BigPowTabLen is the largest cached power for *big.Ints.
	BigPowTabLen = 1e5
)
View Source
const Is32Bit = bits.UintSize == 32

Variables

This section is empty.

Functions

func Abs

func Abs(x int64) uint64

func AbsCmp128

func AbsCmp128(x, y, shift uint64) int

AbsCmp128 compares |x| and |y|*shift in 128 bits.

func Add

func Add(z, x *big.Int, y uint64) *big.Int

Add sets z to x + y and returns z. x is assumed to be unsigned.

func Add128

func Add128(x, y uint64) (z1, z0 uint64)

func BigLength

func BigLength(x *big.Int) int

BigLength returns the number of digits in x.

func BigPow10

func BigPow10(n uint64) *big.Int

BigPow10 computes 10 ** n. The returned *big.Int must not be modified.

func Cmp

func Cmp(x, y uint64) int

func CmpBits

func CmpBits(x, y []big.Word) (r int)

func Length

func Length(x uint64) int

Length returns the number of digits in x.

func Mul128

func Mul128(x, y uint64) (z1, z0 uint64)

Mul128 returns the 128-bit multiplication of x and y.

func MulUint64

func MulUint64(z, x *big.Int, y uint64) *big.Int

MulUint64 sets z to x * y and returns z. x is assumed to be unsigned.

func Pow10

func Pow10(e uint64) (uint64, bool)

Pow10 returns 10 ** e and a boolean indicating whether the result fits into a uint64.

func Pow10Int

func Pow10Int(e uint64) (int64, bool)

Pow10Int returns 10 ** e and a boolean indicating whether the result fits into an int64.

func PowOfTen

func PowOfTen(x uint64) bool

PowOfTen returns strue if x is a power of 10.

func PowOfTenBig

func PowOfTenBig(x *big.Int) bool

PowOfTenBig returns true if x is a power of 10.

func Safe

func Safe(e uint64) bool

func Set128

func Set128(z *big.Int, z1, z0 uint64) *big.Int

func Sub

func Sub(z, x *big.Int, y uint64) *big.Int

Sub sets z to x - y and returns z. x is assumed to be unsigned.

func Words

func Words(x uint64) []big.Word

Types

This section is empty.

Directories

Path Synopsis
Package checked implements basic checked arithmetic.
Package checked implements basic checked arithmetic.

Jump to

Keyboard shortcuts

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