Documentation ¶
Overview ¶
Package ops contains generics for go's built-in operators. two-operator arithmetic:
+: Add %: Mod *: Mul /: Div
two-operator comparison
==: Eq <: Less <=: Leq >: Gt >=: Geq
two-operator binary arithmetic:
|: BinOr &: BinAnd ^: BinXor >>: ShiftRight <<: ShiftLeft
Index ¶
- func Add[T Number | ~string](a, b T) T
- func BitAnd[T constraints.Integer](a, b T) T
- func BitInvert[T constraints.Integer](a T) T
- func BitOr[T constraints.Integer](a, b T) T
- func BitXor[T constraints.Integer](a, b T) T
- func Div[T Number](a, b T) T
- func Eq[T comparable](a, b T) bool
- func Geq[T constraints.Ordered](a, b T) bool
- func Greater[T constraints.Ordered](a, b T) bool
- func Identity[T any](a T) T
- func Leq[T constraints.Ordered](a, b T) bool
- func Less[T constraints.Ordered](a, b T) bool
- func Mod[T constraints.Integer](a, b T) T
- func Mul[T Number](a, b T) T
- func Negate[T constraints.Signed | constraints.Float | constraints.Complex](a T) T
- func Neq[T comparable](a, b T) bool
- func ShiftLeft[T constraints.Integer](a, b T) T
- func ShiftRight[T constraints.Integer](a, b T) T
- func Sub[T Number](a, b T) T
- type Number
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BitInvert ¶
func BitInvert[T constraints.Integer](a T) T
BinInvert is the bitwise negation operator, unary ^.
func Negate ¶
func Negate[T constraints.Signed | constraints.Float | constraints.Complex](a T) T
Negate returns the negative of the integer.
Types ¶
type Number ¶
type Number interface { constraints.Float | constraints.Integer | constraints.Complex }
Number is uint8..=64, int8..=64, float32..=64, complex64..=128
Click to show internal directories.
Click to hide internal directories.