signed256

package
v0.53.0 Latest Latest
Warning

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

Go to latest
Published: May 21, 2026 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const EncodedLen = 33

Variables

This section is empty.

Functions

This section is empty.

Types

type Int

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

Int is a signed integer in the inclusive range [-maxUint256; maxUint256]. It stores sign separately from the absolute uint256 magnitude.

func DecodeBytes

func DecodeBytes(b []byte) (Int, error)

DecodeBytes parses signed uint256 byte format.

func Max

func Max() Int

Max returns the maximal supported value.

func Min

func Min() Int

Min returns the minimal supported value.

func MustParseDecimal

func MustParseDecimal(s string) Int

MustParseDecimal parses s and panics on error.

func NewInt

func NewInt(v int64) Int

NewInt returns a signed value initialized from v.

func NewUint64

func NewUint64(v uint64) Int

NewUint64 returns an unsigned value initialized from v.

func ParseDecimal

func ParseDecimal(s string) (Int, error)

ParseDecimal parses a base-10 signed integer in the inclusive range [-maxUint256; maxUint256].

func ParseNormalizedDecimal

func ParseNormalizedDecimal(neg bool, digits string) (Int, error)

ParseNormalizedDecimal parses already normalized base-10 digits with separately provided sign. digits must be non-empty and contain only decimal digits without leading sign.

func (*Int) Add

func (z *Int) Add(x, y *Int) error

Add sets z to x+y and reports an error if the result is out of range.

func (*Int) Cmp

func (z *Int) Cmp(x *Int) int

Cmp compares z and x and returns:

  • -1 if z < x
  • 0 if z == x
  • +1 if z > x

func (*Int) EncodeBytes

func (z *Int) EncodeBytes() [EncodedLen]byte

EncodeBytes stores z in a signed uint256 byte format: 1 sign byte followed by 32 bytes of magnitude. Negative values are stored as bitwise-inverted magnitude bytes.

func (*Int) FillBytes

func (z *Int) FillBytes(dst []byte)

FillBytes writes z in signed uint256 byte format into dst. dst must be at least EncodedLen bytes long.

func (*Int) SetFromDecimal

func (z *Int) SetFromDecimal(s string) error

SetFromDecimal parses a base-10 signed integer in the inclusive range [-maxUint256; maxUint256].

func (*Int) SetUint64

func (z *Int) SetUint64(v uint64) *Int

SetUint64 sets z to the unsigned value v.

func (Int) String

func (z Int) String() string

String returns the base-10 representation of z.

Jump to

Keyboard shortcuts

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