calculator

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: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCalculator

func NewCalculator[T any](core Core[T]) calculator[T]

Types

type Calculator

type Calculator[T any] interface {
	Core[T]

	Absolute(value T) T
	ComputeBase(base ...T) T
	CountTrailingZeros(value T, base T) (T, error)
	Distribute(value T, ratios ...T) []T
	Equal(subject, comparator T) bool
	GetDivisors(bases ...T) []T
	GreaterThan(subject T, comparator T) bool
	GreaterThanOrEqual(subject T, comparator T) bool
	IsEven(value T) bool
	IsHalf(value T, total T) bool
	LessThan(subject T, comparator T) bool
	LessThanOrEqual(subject T, comparator T) bool
	Maximum(values ...T) T
	Minimum(values ...T) T
	One() T
	Sign(value T) T
	Ten() T
}

type CompareResult

type CompareResult int8
var (
	LT CompareResult = -1
	EQ CompareResult
	GT CompareResult = 1
)

type Core

type Core[T any] interface {
	Add(augend, addend T) T
	Compare(a, b T) CompareResult
	Decrement(value T) T
	Increment(value T) T
	IntegerDivide(dividend, divisor T) (T, error)
	Modulo(dividend, divisor T) (T, error)
	Multiply(multiplicand, multiplier T) T
	Power(base, exponent T) T
	Subtract(minuend, subtrahend T) T
	ToInt(v T) int
	ToString(v T) string
	Zero() T
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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