Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DownBigInt = Down[*big.Int]{}
var DownInt = Down[int]{}
var HalfAwayFromZeroBigInt = HalfAwayFromZero[*big.Int]{}
var HalfAwayFromZeroInt = HalfAwayFromZero[int]{}
var HalfDownBigInt = HalfDown[*big.Int]{}
var HalfDownInt = HalfDown[int]{}
var HalfEvenBigInt = HalfEven[*big.Int]{}
var HalfEvenInt = HalfEven[int]{}
var HalfOddBigInt = HalfOdd[*big.Int]{}
var HalfOddInt = HalfOdd[int]{}
var HalfTowardsZeroBigInt = HalfTowardsZero[*big.Int]{}
var HalfTowardsZeroInt = HalfTowardsZero[int]{}
var HalfUpBigInt = HalfUp[*big.Int]{}
var HalfUpInt = HalfUp[int]{}
var UpBigInt = Up[*big.Int]{}
var UpInt = Up[int]{}
Functions ¶
This section is empty.
Types ¶
type Divider ¶
type Divider[T any] interface { Divide(amount T, factor T, calculator calculator.Calculator[T]) (T, error) }
type Down ¶
type Down[T any] struct{}
Divide and round down. Rounding down happens whenever the quotient is not an integer.
func (Down[T]) Divide ¶
func (Down[T]) Divide(amount T, factor T, calculator calculator.Calculator[T]) (T, error)
type HalfAwayFromZero ¶
type HalfAwayFromZero[T any] struct{}
Divide and round towards "nearest neighbor" unless both neighbors are equidistant, in which case round away from zero.
func (HalfAwayFromZero[T]) Divide ¶
func (HalfAwayFromZero[T]) Divide(amount T, factor T, calculator calculator.Calculator[T]) (T, error)
type HalfDown ¶
type HalfDown[T any] struct{}
Divide and round towards "nearest neighbor" unless both neighbors are equidistant, in which case round down.
Rounding down happens when: - The quotient is half (e.g., -1.5, 1.5). - The quotient is positive and less than half (e.g., 1.4). - The quotient is negative and greater than half (e.g., -1.6).
func (HalfDown[T]) Divide ¶
func (HalfDown[T]) Divide(amount T, factor T, calculator calculator.Calculator[T]) (T, error)
type HalfEven ¶
type HalfEven[T any] struct{}
Divide and round towards "nearest neighbor" unless both neighbors are equidistant, in which case round to the nearest even integer.
func (HalfEven[T]) Divide ¶
func (HalfEven[T]) Divide(amount T, factor T, calculator calculator.Calculator[T]) (T, error)
type HalfOdd ¶
type HalfOdd[T any] struct{}
Divide and round towards "nearest neighbor" unless both neighbors are equidistant, in which case round to the nearest odd integer.
func (HalfOdd[T]) Divide ¶
func (HalfOdd[T]) Divide(amount T, factor T, calculator calculator.Calculator[T]) (T, error)
type HalfTowardsZero ¶
type HalfTowardsZero[T any] struct{}
Divide and round towards "nearest neighbor" unless both neighbors are equidistant, in which case round towards zero.
func (HalfTowardsZero[T]) Divide ¶
func (HalfTowardsZero[T]) Divide(amount T, factor T, calculator calculator.Calculator[T]) (T, error)
type HalfUp ¶
type HalfUp[T any] struct{}
Divide and round towards "nearest neighbor" unless both neighbors are equidistant, in which case round up.
Rounding up happens when: - The quotient is half (e.g., -1.5, 1.5). - The quotient is positive and greater than half (e.g., 1.6). - The quotient is negative and less than half (e.g., -1.4).
func (HalfUp[T]) Divide ¶
func (HalfUp[T]) Divide(amount T, factor T, calculator calculator.Calculator[T]) (T, error)
type Up ¶
type Up[T any] struct{}
Divide and round up. Rounding up happens whenever the quotient is not an integer.
func (Up[T]) Divide ¶
func (Up[T]) Divide(amount T, factor T, calculator calculator.Calculator[T]) (T, error)