misc

package
v0.0.0-...-00de7ca Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: BSD-3-Clause Imports: 1 Imported by: 1

Documentation

Overview

Package misc contains miscellaneous decimal routes.

Deprecated: the functionality has been moved into the decimal

package itself.

Index

Constants

View Source
const (
	// Radix is the base in which decimal arithmetic is effected.
	Radix = decimal.Radix

	// IsCanonical is true since Big decimals are always normalized.
	IsCanonical = decimal.IsCanonical
)

Variables

This section is empty.

Functions

func Canonical

func Canonical(z, x *decimal.Big) *decimal.Big

Canonical sets z to the canonical form of z.

Since Big values are always canonical, it's identical to Copy.

func CmpTotal

func CmpTotal(x, y *decimal.Big) int

CmpTotal compares x and y in a manner similar to the Big.Cmp, but allows ordering of all abstract representations.

In particular, this means NaN values have a defined ordering. From lowest to highest the ordering is:

-NaN
-sNaN
-Infinity
-127
-1.00
-1
-0.000
-0
+0
+1.2300
+1.23
+1E+9
+Infinity
+sNaN
+NaN

func CmpTotalAbs

func CmpTotalAbs(x, y *decimal.Big) int

CmpTotalAbs is like CmpTotal but instead compares the absolute values of x and y.

func CopyAbs

func CopyAbs(z, x *decimal.Big) *decimal.Big

CopyAbs is like Abs, but no flags are changed and the result is not rounded.

func CopyNeg

func CopyNeg(z, x *decimal.Big) *decimal.Big

func Mantissa

func Mantissa(x *decimal.Big) (uint64, bool)

Mantissa returns the mantissa of x and reports whether the mantissa fits into a uint64 and x is finite.

This may be used to convert a decimal representing a monetary value to its most basic unit (e.g., $123.45 to 12345 cents).

func Max

func Max(x ...*decimal.Big) *decimal.Big

Max returns the greater of the provided values.

The result is undefined if no values are are provided.

func MaxAbs

func MaxAbs(x ...*decimal.Big) *decimal.Big

MaxAbs returns the greater of the absolute value of the provided values.

The result is undefined if no values are provided.

func Min

func Min(x ...*decimal.Big) *decimal.Big

Min returns the lesser of the provided values.

The result is undefined if no values are are provided.

func MinAbs

func MinAbs(x ...*decimal.Big) *decimal.Big

MinAbs returns the lesser of the absolute value of the provided values.

The result is undefined if no values are provided.

func NextMinus

func NextMinus(z, x *decimal.Big) *decimal.Big

NextMinus sets z to the smallest representable number that's smaller than x and returns z.

If x is negative infinity the result will be negative infinity. If the result is zero its sign will be negative and its scale will be MinScale.

func NextPlus

func NextPlus(z, x *decimal.Big) *decimal.Big

NextPlus sets z to the largest representable number that's larger than x and returns z.

If x is positive infinity the result will be positive infinity. If the result is zero it will be positive and its scale will be MaxScale.

func SameQuantum

func SameQuantum(x, y *decimal.Big) bool

SameQuantum reports whether x and y have the same exponent (scale).

func SetSignbit

func SetSignbit(z *decimal.Big, sign bool) *decimal.Big

SetSignbit sets z to -z if sign is true, otherwise to +z.

Types

This section is empty.

Jump to

Keyboard shortcuts

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