mathutil

package
v0.3.7 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2020 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CeilDiv8

func CeilDiv8(n int) int

CeilDiv8 divides the input number by 8 and takes the ceiling of that number.

func ClosestPowerOf2

func ClosestPowerOf2(n uint64) uint64

ClosestPowerOf2 returns an integer that is the closest power of 2 that is less than or equal to the argument.

func IntegerSquareRoot

func IntegerSquareRoot(n uint64) uint64

IntegerSquareRoot defines a function that returns the largest possible integer root of a number using a divide and conquer binary search approach:

inspiration: https://www.geeksforgeeks.org/square-root-of-an-integer

func IsPowerOf2

func IsPowerOf2(n uint64) bool

IsPowerOf2 returns true if n is an exact power of two. False otherwise.

func Max

func Max(a uint64, b uint64) uint64

Max returns the larger integer of the two given ones.This is used over the Max function in the standard math library because that max function has to check for some special floating point cases making it slower by a magnitude of 10.

func Min

func Min(a uint64, b uint64) uint64

Min returns the smaller integer of the two given ones. This is used over the Min function in the standard math library because that min function has to check for some special floating point cases making it slower by a magnitude of 10.

func PowerOf2

func PowerOf2(n uint64) uint64

PowerOf2 returns an integer that is the provided exponent of 2. Can only return powers of 2 till 63, after that it overflows

Types

This section is empty.

Jump to

Keyboard shortcuts

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