Documentation
¶
Overview ¶
Package ix contains small integer arithmetic functions in the style of the standard `math` package.
Index ¶
- func Abs[T signed](x T) T
- func CeilDiv[T integer](a, b T) T
- func Concat[T integer](a, b T) T
- func FloorDiv[T integer](a, b T) T
- func GCD[T integer](a, b T) T
- func LCM[T integer](a, b T) T
- func Len[T integer](x T) (n int)
- func Pow[T integer](base, exp T) T
- func RatSign(p, q int) int
- func SLen[T integer](x T) (n int)
- func Sign[T signed](x T) T
- func Sqrt(y int) int
- type Rat
- func (r Rat) Add(s Rat) Rat
- func (r Rat) AddI(n int) Rat
- func (r Rat) Ceil() int
- func (r Rat) Compare(s Rat) int
- func (r Rat) DivI(n int) Rat
- func (r Rat) Floor() int
- func (r Rat) IsInt() bool
- func (r Rat) IsValid() bool
- func (r Rat) Mul(s Rat) Rat
- func (r Rat) MulI(n int) Rat
- func (r Rat) MulIU(n int) Rat
- func (r Rat) Sub(s Rat) Rat
- func (r Rat) SubI(n int) Rat
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CeilDiv ¶
func CeilDiv[T integer](a, b T) T
CeilDiv returns the result of the integer division a / b except always rounded up.
func Concat ¶
func Concat[T integer](a, b T) T
Concat returns the concatenation of two (assumed nonnegative) integer values. For example, ix.Concat(12, 345) == 12345.
func FloorDiv ¶
func FloorDiv[T integer](a, b T) T
FloorDiv returns the result of the integer division a / b except always rounded down, even for negative numbers.
func GCD ¶
func GCD[T integer](a, b T) T
GCD returns the greatest common divisor of the two arguments.
func LCM ¶
func LCM[T integer](a, b T) T
LCM returns the least common multiple of the two arguments.
func Len ¶
func Len[T integer](x T) (n int)
Len returns the number of (decimal) digits in an (assumed nonnegative) integer. Zero is considered to have a length of 0.
func Pow ¶
func Pow[T integer](base, exp T) T
Pow calculates the exponentiation operator for positive integer powers.
func SLen ¶
func SLen[T integer](x T) (n int)
SLen returns the number of (decimal) digits in an integer, including one for sign. Zero is considered to have a length of 1 as well. This is the print width of the integer.