Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Zero = MustNew("0")
Zero is 0 as a Decimal.
Functions ¶
This section is empty.
Types ¶
type Decimal ¶
type Decimal struct {
// contains filtered or unexported fields
}
Decimal represents a fixed-point decimal with an integer and fraction part. MySQL allows a DECIMAL-type to have 1 to 65 digits, with the scale or fraction having 0 to 30 digits. Both the integral and fraction part are therefor stored as big.Int. This Decimal-type is just storage. The caller can access the integral and fraction part through the methods Integral() and Fraction(). There are no methods to do calculations.
func New ¶
New takes string s as decimal (for example "3.14"), and stores the integer and fraction in a newly instantiated Decimal object. Only base 10 is supported, so no `0x` prefixes for example. The call is responsible to remove any thousand separators.
func NewDecimalFromBCD ¶
NewDecimalFromBCD decodes bcd or Binary-Coded Decimal and returns a new instance of Decimal.
func (*Decimal) Encode ¶
Encode will encode d as Binary-Coded Decimal (BCD), making it ready to send it to MySQL.