snum

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Snum

type Snum struct {
	// contains filtered or unexported fields
}

func New

func New[T SnumConst](num T) *Snum

func (*Snum) Abs

func (t *Snum) Abs()

func (*Snum) Add

func (t *Snum) Add(sn *Snum)

func (*Snum) Cmp

func (t *Snum) Cmp(sn *Snum) int

Output:

if( t < _pt ) -> -1 if( t == _pt ) -> 0 if( t > _pt ) -> +1

func (*Snum) Copy

func (t *Snum) Copy() *Snum

func (*Snum) Div

func (t *Snum) Div(sn *Snum)

func (*Snum) GetRaw

func (t *Snum) GetRaw() (bigNum *big.Int, lenDecimal int, isMinus bool)

func (*Snum) GetStr

func (t *Snum) GetStr() (sn string)

func (*Snum) GetUint64

func (t *Snum) GetUint64() (u8 uint64, err error)

func (*Snum) GroupDown

func (t *Snum) GroupDown(step int)

Output:

x             step       GroupDown      Group_up
123.321         -4         123.321       123.321
123.321         -3         123.321       123.321
123.321         -2         123.32        123.33
123.321         -1         123.3         123.4
123.321          0         123           124
123.321          1         120           130
123.321          2         100           200
123.321          3         0             1000
123.321          4         0             10000

func (*Snum) GroupUp

func (t *Snum) GroupUp(step int)

func (*Snum) Init

func (t *Snum) Init()

func (*Snum) IsZero

func (t *Snum) IsZero() bool

func (*Snum) IsZeroOver

func (t *Snum) IsZeroOver() bool

func (*Snum) IsZeroUnder

func (t *Snum) IsZeroUnder() bool

func (*Snum) MarshalJSON

func (t *Snum) MarshalJSON() ([]byte, error)

func (*Snum) Mul

func (t *Snum) Mul(sn *Snum)

func (*Snum) Neg

func (t *Snum) Neg()

func (*Snum) Pow

func (t *Snum) Pow(num int64)

func (*Snum) Round

func (t *Snum) Round(step int)

Output:

  x         Round    Round_down      Round_up
2.9             3             2             3
2.5             2             2             3
2.1             2             2             3
2               2             2             2

-2 -2 -2 -2 -2.1 -2 -2 -3 -2.5 -3 -2 -3 -2.9 -3 -2 -3

func (*Snum) RoundDown

func (t *Snum) RoundDown(step int)

func (*Snum) RoundUp

func (t *Snum) RoundUp(step int)

func (*Snum) SetRaw

func (t *Snum) SetRaw(big *big.Int, lenDecimal int, isMinus bool)

func (*Snum) SetStr

func (t *Snum) SetStr(sn string) (err error)

func (*Snum) SetUint64

func (t *Snum) SetUint64(u8 uint64) (err error)

func (*Snum) SetZero

func (t *Snum) SetZero()

func (*Snum) String

func (t *Snum) String() string

func (*Snum) Sub

func (t *Snum) Sub(sn *Snum)

func (*Snum) TrimDigit

func (t *Snum) TrimDigit(lenInteger, lenDecimal int) error

func (*Snum) UnmarshalJSON

func (t *Snum) UnmarshalJSON(bt []byte) error

type SnumConst

type SnumConst interface {
	*Snum | int | int32 | int64 | uint | uint32 | uint64 | string
}

Jump to

Keyboard shortcuts

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