package decimal128

Import Path
	github.com/apache/arrow-go/v18/arrow/decimal128 (on go.dev)

Dependency Relation
	imports 6 packages, and imported by 7 packages

Involved Source Files decimal128.go
Package-Level Type Names (only one)
/* sort by: | */
Num represents a signed 128-bit integer in two's complement. Calculations wrap around and overflow is ignored. For a discussion of the algorithms, look at Knuth's volume 2, Semi-numerical Algorithms section 4.3.1. Adapted from the Apache ORC C++ implementation Abs returns a new decimal128.Num that contains the absolute value of n ( Num) Add(rhs Num) Num while the code would be simpler to just do lsh/rsh and add it turns out from benchmarking that calling SetBits passing in the words and negating ends up being >2x faster Cmp compares the numbers represented by n and other and returns: +1 if n > other 0 if n == other -1 if n < other ( Num) Div(rhs Num) (res, rem Num) FitsInPrecision returns true or false if the value currently held by n would fit within precision (0 < prec <= 38) without losing any data. Greater returns true if the value represented by n is > other GreaterEqual returns true if the value represented by n is >= other HighBits returns the high bits of the two's complement representation of the number. IncreaseScaleBy returns a new decimal128.Num with the value scaled up by the desired amount. Must be 0 <= increase <= 38. Any data loss from scaling is ignored. If you wish to prevent data loss, use Rescale which will return an error if data loss is detected. Less returns true if the value represented by n is < other LessEqual returns true if the value represented by n is <= other LowBits returns the low bits of the two's complement representation of the number. ( Num) Mul(rhs Num) Num Negate returns a copy of this Decimal128 value but with the sign negated ( Num) Pow(rhs Num) Num ReduceScaleBy returns a new decimal128.Num with the value scaled down by the desired amount and, if 'round' is true, the value will be rounded accordingly. Assumes 0 <= reduce <= 38. Any data loss from scaling is ignored. If you wish to prevent data loss, use Rescale which will return an error if data loss is detected. Rescale returns a new decimal128.Num with the value updated assuming the current value is scaled to originalScale with the new value scaled to newScale. If rescaling this way would cause data loss, an error is returned instead. Sign returns: -1 if x < 0 0 if x == 0 +1 if x > 0 ( Num) Sub(rhs Num) Num ( Num) ToBigFloat(scale int32) *big.Float ToFloat32 returns a float32 value representative of this decimal128.Num, but with the given scale. ToFloat64 returns a float64 value representative of this decimal128.Num, but with the given scale. ( Num) ToString(scale int32) string Num : github.com/apache/arrow-go/v18/arrow/decimal.Num[decimal.Decimal128] func FromBigInt(v *big.Int) (n Num) func FromFloat32(v float32, prec, scale int32) (Num, error) func FromFloat64(v float64, prec, scale int32) (Num, error) func FromI64(v int64) Num func FromString(v string, prec, scale int32) (n Num, err error) func FromU64(v uint64) Num func GetHalfScaleMultiplier(pow int) Num func GetMaxValue(prec int32) Num func GetScaleMultiplier(pow int) Num func Max(first Num, rest ...Num) Num func Min(first Num, rest ...Num) Num func New(hi int64, lo uint64) Num func Num.Abs() Num func Num.Add(rhs Num) Num func Num.Div(rhs Num) (res, rem Num) func Num.IncreaseScaleBy(increase int32) Num func Num.Mul(rhs Num) Num func Num.Negate() Num func Num.Pow(rhs Num) Num func Num.ReduceScaleBy(reduce int32, round bool) Num func Num.Rescale(originalScale, newScale int32) (out Num, err error) func Num.Sub(rhs Num) Num func Max(first Num, rest ...Num) Num func Max(first Num, rest ...Num) Num func Min(first Num, rest ...Num) Num func Min(first Num, rest ...Num) Num func Num.Add(rhs Num) Num func Num.Cmp(other Num) int func Num.Div(rhs Num) (res, rem Num) func Num.Greater(other Num) bool func Num.GreaterEqual(other Num) bool func Num.Less(other Num) bool func Num.LessEqual(other Num) bool func Num.Mul(rhs Num) Num func Num.Pow(rhs Num) Num func Num.Sub(rhs Num) Num func github.com/apache/arrow-go/v18/arrow/decimal256.FromDecimal128(n Num) decimal256.Num func github.com/apache/arrow-go/v18/arrow/scalar.NewDecimal128Scalar(val Num, typ arrow.DataType) *scalar.Decimal128 var MaxDecimal128
Package-Level Functions (total 12)
FromBigInt will convert a big.Int to a Num, if the value in v has a BitLen > 128, this will panic.
FromFloat32 returns a new decimal128.Num constructed from the given float32 value using the provided precision and scale. Will return an error if the value cannot be accurately represented with the desired precision and scale.
FromFloat64 returns a new decimal128.Num constructed from the given float64 value using the provided precision and scale. Will return an error if the value cannot be accurately represented with the desired precision and scale.
FromI64 returns a new signed 128-bit integer value from the provided int64 one.
func FromString(v string, prec, scale int32) (n Num, err error)
FromU64 returns a new signed 128-bit integer value from the provided uint64 one.
func GetMaxValue(prec int32) Num
Max returns the largest Decimal128 that was passed in the arguments
Min returns the smallest Decimal128 that was passed in the arguments
New returns a new signed 128-bit integer value.
Package-Level Variables (only one)
Package-Level Constants (total 2)
const MaxPrecision = 38
const MaxScale = 38