jsnum

package
v0.0.0-...-7d7180d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 24, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package jsnum provides JS-like number handling.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParsePseudoBigInt

func ParsePseudoBigInt(stringValue string) string

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 Inf

func Inf(sign int) Number

func NaN

func NaN() Number

func (Number) Abs

func (x Number) Abs() Number

func (Number) Floor

func (x Number) Floor() Number

func (Number) IsInf

func (n Number) IsInf() bool

func (Number) IsNaN

func (n Number) IsNaN() bool

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL