# README
Decimal package
Package decimal provides tools for working with YDB's decimal types.
Decimal types are stored as int128 values inside YDB and represented as 16-byte arrays in ydb package and as *math/big.Int in ydb/decimal package.
Note that returned big.Int values are scaled. That is, math operations must be prepared keeping in mind scaling factor:
import (
"ydb/decimal"
"math/big"
)
var scaleFactor = big.NewInt(10000000000) // Default scale is 9.
func main() {
x := decimal.FromInt128([16]byte{...})
x.Add(x, big.NewInt(42)) // Incorrect.
x.Add(x, scale(42)) // Correct.
}
func scale(n int64) *big.Int {
x := big.NewInt(n)
return x.Mul(x, scaleFactor)
}
# Functions
No description provided by the author
BigIntToByte returns the 16-byte array representation of x.
Err returns "error" value.
Format returns the string representation of x with the given precision and scale.
FromBytes converts bytes representation of decimal to big integer.
FromInt128 returns big integer from given array.
Inf returns infinity value.
IsErr reports whether x is an "error" value.
IsInf reports whether x is an infinity.
IsNaN reports whether x is a "not-a-number" value.
NaN returns "not-a-number" value.
Parse interprets a string s with the given precision and scale and returns the corresponding big integer.