Documentation
¶
Index ¶
- Variables
- type Number
- func (r *Number) Add(other *Number) *Number
- func (r *Number) Cmp(other *Number) int
- func (r *Number) Constructive() constructive.Real
- func (r *Number) Divide(other *Number) *Number
- func (r *Number) Inverse() *Number
- func (r *Number) IsZero() bool
- func (r *Number) Multiply(other *Number) *Number
- func (r *Number) Negate() *Number
- func (r *Number) ShiftLeft(n int) *Number
- func (r *Number) ShiftRight(n int) *Number
- func (r *Number) Sign() int
- func (r *Number) String() string
- func (r *Number) Subtract(other *Number) *Number
Constants ¶
This section is empty.
Variables ¶
View Source
var One = sync.OnceValue(func() *Number { return New64(1, 1) })
View Source
var Zero = sync.OnceValue(func() *Number { return New64(0, 1) })
Functions ¶
This section is empty.
Types ¶
type Number ¶
type Number struct {
// contains filtered or unexported fields
}
Number represents a rational number.
func FromRational ¶
FromRational creates a new rational number from a big.Rat.
func (*Number) Cmp ¶
Cmp compares two rational numbers: -1 if r < other, 0 if r == other, 1 if r > other.
func (*Number) Constructive ¶
func (r *Number) Constructive() constructive.Real
Constructive converts the rational number to a constructive real.
func (*Number) ShiftLeft ¶
ShiftLeft shifts the rational number left by n bits (multiplies by 2^n). Supports signed shifts: negative n shifts right.
func (*Number) ShiftRight ¶
ShiftRight shifts the rational number right by n bits (divides by 2^n). Supports signed shifts: negative n shifts left.
func (*Number) Sign ¶
Sign returns the sign of the rational number: -1 for negative, 0 for zero, 1 for positive.
Click to show internal directories.
Click to hide internal directories.