Documentation
¶
Index ¶
- type Bucket
- type Decimal
- func (d Decimal) Add(other Decimal) Decimal
- func (d Decimal) Ceil() Integer
- func (d Decimal) CompareTo(other Decimal) int
- func (d Decimal) Equals(other Decimal) bool
- func (d Decimal) Floor() Integer
- func (d Decimal) Format() string
- func (d Decimal) IsExact() bool
- func (d Decimal) Mul(other Decimal) Decimal
- func (d Decimal) Scale() int
- func (d Decimal) SetScale(nsig int, ceiling bool) Decimal
- func (d Decimal) String() string
- func (d Decimal) Sub(other Decimal) Decimal
- func (d Decimal) System() NumeralSystem
- type Integer
- func (i Integer) Add(other Integer) Integer
- func (i Integer) CompareTo(other Integer) int
- func (i Integer) Complement() Integer
- func (i Integer) ComplementDigits(digits int) Integer
- func (i Integer) Equals(other Integer) bool
- func (i Integer) Format() string
- func (i Integer) IsOne() bool
- func (i Integer) IsZero() bool
- func (i Integer) MagAt(index int) int
- func (i Integer) Mul(other Integer) Integer
- func (i Integer) Negate() Integer
- func (i Integer) ShiftLeft(times int) Integer
- func (i Integer) ShiftRight(times int) Integer
- func (i Integer) String() string
- func (i Integer) Sub(other Integer) Integer
- func (i Integer) System() NumeralSystem
- type NumeralSystem
- type Rank
- func (r Rank) Between(other Rank) (Rank, error)
- func (r Rank) CompareTo(other Rank) int
- func (r Rank) Equals(other Rank) bool
- func (r Rank) Format() string
- func (r Rank) GenNext() Rank
- func (r Rank) GenPrev() Rank
- func (r Rank) GetBucket() Bucket
- func (r Rank) GetDecimal() Decimal
- func (r Rank) InNextBucket() Rank
- func (r Rank) InPrevBucket() Rank
- func (r Rank) IsMax() bool
- func (r Rank) IsMin() bool
- func (r Rank) String() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bucket ¶
type Bucket int
Bucket represents one of the 3 rank buckets (0, 1, 2).
func BucketFrom ¶
BucketFrom parses a bucket from a string ("0", "1", or "2").
func ResolveBucket ¶
ResolveBucket resolves a bucket by numeric ID.
type Decimal ¶
type Decimal struct {
// contains filtered or unexported fields
}
Decimal is an arbitrary-precision decimal built on Integer.
func DecimalFrom ¶
DecimalFrom wraps an Integer with scale 0.
func MakeDecimal ¶
MakeDecimal creates a Decimal, trimming trailing fractional zeros.
func ParseDecimal ¶
func ParseDecimal(s string, sys NumeralSystem) (Decimal, error)
ParseDecimal parses a string with an optional radix point into a Decimal.
func (Decimal) System ¶
func (d Decimal) System() NumeralSystem
type Integer ¶
type Integer struct {
// contains filtered or unexported fields
}
Integer is an arbitrary-precision integer in any base. Magnitude is stored little-endian (index 0 = least significant digit).
func NewInteger ¶
func NewInteger(sys NumeralSystem, sign int, mag []int) Integer
NewInteger creates an Integer, trimming trailing zeros.
func ParseInteger ¶
func ParseInteger(s string, sys NumeralSystem) (Integer, error)
ParseInteger parses a string into an Integer.
func Zero ¶
func Zero(sys NumeralSystem) Integer
Zero returns the zero Integer for the given system.
func (Integer) Complement ¶
func (Integer) ComplementDigits ¶
func (Integer) ShiftRight ¶
func (Integer) System ¶
func (i Integer) System() NumeralSystem
type NumeralSystem ¶
type NumeralSystem interface {
Base() int
PositiveChar() byte
NegativeChar() byte
RadixPointChar() byte
ToDigit(ch byte) (int, error)
ToChar(digit int) byte
}
NumeralSystem defines the interface for a base-N numeral system.
var ( System10 NumeralSystem = numeralSystem10{} System36 NumeralSystem = numeralSystem36{} System64 NumeralSystem = numeralSystem64{} )
type Rank ¶
type Rank struct {
// contains filtered or unexported fields
}
Rank is a lexicographically sortable rank string.
func (Rank) Between ¶
Between returns the midpoint rank between r and other. Returns an error if the ranks are in different buckets or have the same decimal.