Documentation
¶
Overview ¶
Package dynamonum implements DynamoDB's exact decimal Number type: up to 38 significant digits, magnitude 1E-130..9.9999999999999999999999999999999999999E+125.
Index ¶
Constants ¶
View Source
const (
// MaxDigits is the maximum number of significant digits.
MaxDigits = 38
)
Variables ¶
View Source
var ( // ErrInvalid is returned for text that is not a decimal number. ErrInvalid = errors.New("not a valid number") // ErrOverflow is returned when the magnitude exceeds the supported range. ErrOverflow = errors.New( "Number overflow. Attempting to store a number with magnitude larger than supported range") // ErrUnderflow is returned when a non-zero magnitude is below the supported range. ErrUnderflow = errors.New( "Number underflow. Attempting to store a number with magnitude smaller than supported range") // ErrTooManyDigits is returned when a value needs more than 38 significant digits. ErrTooManyDigits = errors.New( "Attempting to store more than 38 significant digits in a Number") )
Functions ¶
Types ¶
type Num ¶
type Num struct {
// contains filtered or unexported fields
}
Num is a normalised decimal: value = (+/-) d[:n] * 10^scale, with no leading or trailing zero digit. Non-zero integers of at most 18 digits are held only in small (the fast path); the digit fields are then unset. The zero value is zero. Equal values have equal representations, so Num is comparable with ==.
func FromFloat ¶
FromFloat converts a float64 via its shortest decimal form; false if not finite or out of range.
Click to show internal directories.
Click to hide internal directories.