i64

package
v0.0.0-...-5dc6d85 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2016 License: BSD-3-Clause Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Abs

func Abs(x int64) int64

Abs returns the absolute value of x.

func BitCount

func BitCount(v int64) int64

Bitcount returns the number of set bits in v. Recall that Go represent integers in two's complement.

func Cbrt

func Cbrt(n int64) int64

Cbrt returns the integer cube root of n. That is to say, the r such that:

r * r * r <= n && n < (r + 1) * (r + 1) * (r + 1) //for positive n r * r * r >= n && n > (r + 1) * (r + 1) * (r + 1) //for negative n

Adapted from code found in Hacker's Delight, fixed by Fabian Giessen https://gist.github.com/729557

func GCD

func GCD(a, b int64) int64

GCD returns the greatest common divisor of a and b.

func Log10

func Log10(n int64) int64

Log10 returns log base 10 of n. n <= 0 returns -1

func Log2

func Log2(n int64) int64

Log2 returns log base 2 of n. It's the same as index of the highest bit set in n. n <= 0 return -1.

func Max

func Max(x, y int64) int64

Max(x,y) returns the larger of x or y

func Min

func Min(x, y int64) int64

Min(x,y) returns the smaller of x or y

func Pow

func Pow(x, y int64) (r int64)

Pow returns x**y, the base-x exponential of y.

func Sqrt

func Sqrt(x int64) int64

Sqrt returns the square root of x. x < 0 returns -1. Based on a C implementation of Newton's Method using bitshifting, originally found here: http://www.codecodex.com/wiki/Calculate_an_integer_square_root#C

func TrailingZeros

func TrailingZeros(v int64) int64

TrailingZeros returns a byte with the number of trailing 0 bits in v. Remember that Go represents negative integers in two's complement. If v is 0, it returns 0.

Types

This section is empty.

Jump to

Keyboard shortcuts

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