Documentation ¶
Overview ¶
Package misc contains miscellaneous decimal routes.
Index ¶
- Constants
- func Canonical(z, x *decimal.Big) *decimal.Big
- func CmpTotal(x, y *decimal.Big) int
- func CmpTotalAbs(x, y *decimal.Big) int
- func CopyAbs(z, x *decimal.Big) *decimal.Big
- func CopyNeg(z, x *decimal.Big) *decimal.Big
- func Mantissa(x *decimal.Big) (uint64, bool)
- func Max(x ...*decimal.Big) *decimal.Big
- func MaxAbs(x ...*decimal.Big) *decimal.Big
- func Min(x ...*decimal.Big) *decimal.Big
- func MinAbs(x ...*decimal.Big) *decimal.Big
- func NextMinus(z, x *decimal.Big) *decimal.Big
- func NextPlus(z, x *decimal.Big) *decimal.Big
- func SameQuantum(x, y *decimal.Big) bool
- func SetSignbit(z *decimal.Big, sign bool) *decimal.Big
Constants ¶
const ( // Radix is the base in which decimal arithmetic is effected. Radix = 10 // IsCanonical is true since Big decimals are always normalized. IsCanonical = true )
Variables ¶
This section is empty.
Functions ¶
func Canonical ¶
Canonical sets z to the canonical form of z.
Since Big values are always canonical, it's identical to Copy.
func CmpTotal ¶
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 ¶
CmpTotalAbs is like CmpTotal but instead compares the absolute values of x and y.
func Mantissa ¶
Mantissa returns the mantissa of x. If the mantissa cannot fit into a uint64 or x is not finite, the bool will be false. This may be used to convert a decimal representing a monetary to its most basic unit (e.g., $123.45 to 12345 cents.)
func Max ¶
Max returns the greater of the provided values.
The result is undefined if no values are are provided.
func MaxAbs ¶
MaxAbs returns the greater of the absolute value of the provided values.
The result is undefined if no values are provided.
func Min ¶
Min returns the lesser of the provided values.
The result is undefined if no values are are provided.
func MinAbs ¶
MinAbs returns the lesser of the absolute value of the provided values. The result is undefined if no values are provided.
func NextMinus ¶
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 ¶
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 ¶
SameQuantum returns true if x and y have the same exponent (scale).
Types ¶
This section is empty.