divide

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DownBigInt = Down[*big.Int]{}
View Source
var DownInt = Down[int]{}
View Source
var HalfAwayFromZeroBigInt = HalfAwayFromZero[*big.Int]{}
View Source
var HalfAwayFromZeroInt = HalfAwayFromZero[int]{}
View Source
var HalfDownBigInt = HalfDown[*big.Int]{}
View Source
var HalfDownInt = HalfDown[int]{}
View Source
var HalfEvenBigInt = HalfEven[*big.Int]{}
View Source
var HalfEvenInt = HalfEven[int]{}
View Source
var HalfOddBigInt = HalfOdd[*big.Int]{}
View Source
var HalfOddInt = HalfOdd[int]{}
View Source
var HalfTowardsZeroBigInt = HalfTowardsZero[*big.Int]{}
View Source
var HalfTowardsZeroInt = HalfTowardsZero[int]{}
View Source
var HalfUpBigInt = HalfUp[*big.Int]{}
View Source
var HalfUpInt = HalfUp[int]{}
View Source
var UpBigInt = Up[*big.Int]{}
View Source
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)

Jump to

Keyboard shortcuts

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