Documentation
¶
Overview ¶
Package jsnum provides JS-like number handling.
Index ¶
- func ParsePseudoBigInt(stringValue string) string
- type Number
- func (x Number) Abs() Number
- func (x Number) BitwiseAND(y Number) Number
- func (x Number) BitwiseNOT() Number
- func (x Number) BitwiseOR(y Number) Number
- func (x Number) BitwiseXOR(y Number) Number
- func (base Number) Exponentiate(exponent Number) Number
- func (x Number) Floor() Number
- func (n Number) IsInf() bool
- func (n Number) IsNaN() bool
- func (x Number) LeftShift(y Number) Number
- func (n Number) Remainder(d Number) Number
- func (x Number) SignedRightShift(y Number) Number
- func (n Number) String() string
- func (x Number) UnsignedRightShift(y Number) Number
- type PseudoBigInt
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParsePseudoBigInt ¶
Types ¶
type Number ¶
type Number float64
Number represents a JS-like number.
All operations that can be performed directly on this type (e.g., conversion, arithmetic, etc.) behave as they would in JavaScript, but any other operation should use this type's methods, not the "math" package and conversions.
const ( MaxSafeInteger Number = 1<<53 - 1 MinSafeInteger Number = -MaxSafeInteger )
func FromString ¶
https://tc39.es/ecma262/2024/multipage/abstract-operations.html#sec-stringtonumber
func (Number) BitwiseAND ¶
func (Number) BitwiseNOT ¶
func (Number) BitwiseXOR ¶
func (Number) Exponentiate ¶
func (Number) SignedRightShift ¶
func (Number) UnsignedRightShift ¶
type PseudoBigInt ¶
type PseudoBigInt struct { Negative bool // true if the value is a non-zero negative number. Base10Value string // The absolute value in base 10 with no leading zeros. The value zero is represented as an empty string. }
PseudoBigInt represents a JS-like bigint. The zero state of the struct represents the value 0.
func NewPseudoBigInt ¶
func NewPseudoBigInt(value string, negative bool) PseudoBigInt
func ParseValidBigInt ¶
func ParseValidBigInt(text string) PseudoBigInt
func (PseudoBigInt) Sign ¶
func (value PseudoBigInt) Sign() int
func (PseudoBigInt) String ¶
func (value PseudoBigInt) String() string
Click to show internal directories.
Click to hide internal directories.