bal3

package
v0.0.0-...-d51f9a1 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TC16 = tc16
View Source
var TC32 = tc32
View Source
var TC4 = tc4
View Source
var TC6 = tc6
View Source
var TC8 = tc8
View Source
var TC9 = tc9

Functions

func FormatBase27

func FormatBase27[T Unsigned](tc TryteCore[T], a T) string

func ParseBase27

func ParseBase27[T Unsigned](tc TryteCore[T], s string) (T, error)

Types

type BinaryFunc

type BinaryFunc func(Trit, Trit) Trit

type Bt

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

Balanced ternary

func NewBt

func NewBt() *Bt

func ParseBt

func ParseBt(s string) (*Bt, error)

func (*Bt) Format

func (b *Bt) Format() string

func (*Bt) IsNegative

func (b *Bt) IsNegative() bool

x < 0

func (*Bt) IsPositive

func (b *Bt) IsPositive() bool

x > 0

func (*Bt) IsZero

func (b *Bt) IsZero() bool

x == 0

func (*Bt) Neg

func (p *Bt) Neg() *Bt

func (*Bt) Sign

func (b *Bt) Sign() int

func (*Bt) String

func (b *Bt) String() string

func (*Bt) TritLen

func (b *Bt) TritLen() int

TritLen returns the length of the absolute value of b in trits. The trit length of 0 is 0.

type Rand

type Rand = rand.Rand

type Trit

type Trit int

type Tryte16

type Tryte16 uint32

16 trits

func (Tryte16) Add

func (a Tryte16) Add(b Tryte16) (c Tryte16)

func (Tryte16) Compare

func (a Tryte16) Compare(b Tryte16) int

func (Tryte16) Div

func (a Tryte16) Div(b Tryte16) Tryte16

func (Tryte16) Equal

func (a Tryte16) Equal(b Tryte16) bool

func (Tryte16) IsZero

func (a Tryte16) IsZero() bool

func (Tryte16) Less

func (a Tryte16) Less(b Tryte16) bool

func (Tryte16) Mul

func (a Tryte16) Mul(b Tryte16) Tryte16

func (Tryte16) Neg

func (a Tryte16) Neg() (b Tryte16)

func (Tryte16) Shl

func (a Tryte16) Shl(i int) Tryte16

func (Tryte16) Shr

func (a Tryte16) Shr(i int) Tryte16

func (Tryte16) String

func (a Tryte16) String() string

func (Tryte16) Sub

func (a Tryte16) Sub(b Tryte16) (c Tryte16)

func (Tryte16) ToInt64

func (a Tryte16) ToInt64() int64

type Tryte32

type Tryte32 uint64

32 trits

func (Tryte32) Add

func (a Tryte32) Add(b Tryte32) (c Tryte32)

func (Tryte32) Compare

func (a Tryte32) Compare(b Tryte32) int

func (Tryte32) Div

func (a Tryte32) Div(b Tryte32) Tryte32

func (Tryte32) Equal

func (a Tryte32) Equal(b Tryte32) bool

func (Tryte32) IsZero

func (a Tryte32) IsZero() bool

func (Tryte32) Less

func (a Tryte32) Less(b Tryte32) bool

func (Tryte32) Mul

func (a Tryte32) Mul(b Tryte32) Tryte32

func (Tryte32) Neg

func (a Tryte32) Neg() (b Tryte32)

func (Tryte32) Shl

func (a Tryte32) Shl(i int) Tryte32

func (Tryte32) Shr

func (a Tryte32) Shr(i int) Tryte32

func (Tryte32) String

func (a Tryte32) String() string

func (Tryte32) Sub

func (a Tryte32) Sub(b Tryte32) (c Tryte32)

func (Tryte32) ToInt64

func (a Tryte32) ToInt64() int64

type Tryte4

type Tryte4 uint8

4 trits

func (Tryte4) Add

func (a Tryte4) Add(b Tryte4) (c Tryte4)

func (Tryte4) Compare

func (a Tryte4) Compare(b Tryte4) int

func (Tryte4) Div

func (a Tryte4) Div(b Tryte4) Tryte4

func (Tryte4) Equal

func (a Tryte4) Equal(b Tryte4) bool

func (Tryte4) IsZero

func (a Tryte4) IsZero() bool

func (Tryte4) Less

func (a Tryte4) Less(b Tryte4) bool

func (Tryte4) Mul

func (a Tryte4) Mul(b Tryte4) Tryte4

func (Tryte4) Neg

func (a Tryte4) Neg() (b Tryte4)

func (Tryte4) Shl

func (a Tryte4) Shl(i int) Tryte4

func (Tryte4) Shr

func (a Tryte4) Shr(i int) Tryte4

func (Tryte4) String

func (a Tryte4) String() string

func (Tryte4) Sub

func (a Tryte4) Sub(b Tryte4) (c Tryte4)

func (Tryte4) ToInt64

func (a Tryte4) ToInt64() int64

type Tryte6

type Tryte6 uint16

6 trits

func (Tryte6) Add

func (a Tryte6) Add(b Tryte6) (c Tryte6)

func (Tryte6) Compare

func (a Tryte6) Compare(b Tryte6) int

func (Tryte6) Div

func (a Tryte6) Div(b Tryte6) Tryte6

func (Tryte6) Equal

func (a Tryte6) Equal(b Tryte6) bool

func (Tryte6) IsZero

func (a Tryte6) IsZero() bool

func (Tryte6) Less

func (a Tryte6) Less(b Tryte6) bool

func (Tryte6) Mul

func (a Tryte6) Mul(b Tryte6) Tryte6

func (Tryte6) Neg

func (a Tryte6) Neg() (b Tryte6)

func (Tryte6) Shl

func (a Tryte6) Shl(i int) Tryte6

func (Tryte6) Shr

func (a Tryte6) Shr(i int) Tryte6

func (Tryte6) String

func (a Tryte6) String() string

func (Tryte6) Sub

func (a Tryte6) Sub(b Tryte6) (c Tryte6)

func (Tryte6) ToInt64

func (a Tryte6) ToInt64() int64

type Tryte8

type Tryte8 uint16

8 trits

func (Tryte8) Add

func (a Tryte8) Add(b Tryte8) (c Tryte8)

func (Tryte8) Compare

func (a Tryte8) Compare(b Tryte8) int

func (Tryte8) Div

func (a Tryte8) Div(b Tryte8) Tryte8

func (Tryte8) Equal

func (a Tryte8) Equal(b Tryte8) bool

func (Tryte8) IsZero

func (a Tryte8) IsZero() bool

func (Tryte8) Less

func (a Tryte8) Less(b Tryte8) bool

func (Tryte8) Mul

func (a Tryte8) Mul(b Tryte8) Tryte8

func (Tryte8) Neg

func (a Tryte8) Neg() (b Tryte8)

func (Tryte8) Shl

func (a Tryte8) Shl(i int) Tryte8

func (Tryte8) Shr

func (a Tryte8) Shr(i int) Tryte8

func (Tryte8) String

func (a Tryte8) String() string

func (Tryte8) Sub

func (a Tryte8) Sub(b Tryte8) (c Tryte8)

func (Tryte8) ToInt64

func (a Tryte8) ToInt64() int64

type Tryte9

type Tryte9 uint32

9 trits

func (Tryte9) Add

func (a Tryte9) Add(b Tryte9) (c Tryte9)

func (Tryte9) Compare

func (a Tryte9) Compare(b Tryte9) int

func (Tryte9) Div

func (a Tryte9) Div(b Tryte9) Tryte9

func (Tryte9) Equal

func (a Tryte9) Equal(b Tryte9) bool

func (Tryte9) IsZero

func (a Tryte9) IsZero() bool

func (Tryte9) Less

func (a Tryte9) Less(b Tryte9) bool

func (Tryte9) Mul

func (a Tryte9) Mul(b Tryte9) Tryte9

func (Tryte9) Neg

func (a Tryte9) Neg() (b Tryte9)

func (Tryte9) Shl

func (a Tryte9) Shl(i int) Tryte9

func (Tryte9) Shr

func (a Tryte9) Shr(i int) Tryte9

func (Tryte9) String

func (a Tryte9) String() string

func (Tryte9) Sub

func (a Tryte9) Sub(b Tryte9) (c Tryte9)

func (Tryte9) ToInt64

func (a Tryte9) ToInt64() int64

type TryteCore

type TryteCore[T Unsigned] struct {
	// contains filtered or unexported fields
}

func MakeTryteCore

func MakeTryteCore[T Unsigned](n int) TryteCore[T]

n - number of trits

func (TryteCore[T]) Add

func (tc TryteCore[T]) Add(x, y T, carryIn Trit) (res T, carryOut Trit)

func (TryteCore[T]) Compare

func (tc TryteCore[T]) Compare(a, b T) int

The result will be 0 if a == b, -1 if a < b, and +1 if a > b.

func (TryteCore[T]) DoBinary

func (tc TryteCore[T]) DoBinary(a, b T, f BinaryFunc) T

func (TryteCore[T]) DoUnary

func (tc TryteCore[T]) DoUnary(a T, f UnaryFunc) T

func (TryteCore[T]) Equal

func (tc TryteCore[T]) Equal(a, b T) bool

a == n

func (TryteCore[T]) Format

func (tc TryteCore[T]) Format(a T) string

func (TryteCore[T]) FormatAllTrits

func (tc TryteCore[T]) FormatAllTrits(a T) string

func (TryteCore[T]) Greater

func (tc TryteCore[T]) Greater(a, b T) bool

a > b

func (TryteCore[T]) GreaterOrEqual

func (tc TryteCore[T]) GreaterOrEqual(a, b T) bool

The "greater than or equal to" sign: >= a >= b

func (TryteCore[T]) Int64ToTrite

func (tc TryteCore[T]) Int64ToTrite(v int64) (a T, rest int64)

func (TryteCore[T]) IsNegative

func (tc TryteCore[T]) IsNegative(x T) bool

x < 0

func (TryteCore[T]) IsPositive

func (tc TryteCore[T]) IsPositive(x T) bool

x > 0

func (TryteCore[T]) IsZero

func (tc TryteCore[T]) IsZero(x T) bool

x == 0

func (TryteCore[T]) Len

func (tc TryteCore[T]) Len(x T) int

Len returns the minimum number of trits required to represent x; the result is 0 for x == 0.

func (TryteCore[T]) Less

func (tc TryteCore[T]) Less(a, b T) bool

a < b

func (TryteCore[T]) LessOrEqual

func (tc TryteCore[T]) LessOrEqual(a, b T) bool

The "less than or equal to" sign: <= a <= b

func (TryteCore[T]) Limits

func (tc TryteCore[T]) Limits() (min, max T)

Bounds

func (TryteCore[T]) LimitsInt64

func (tc TryteCore[T]) LimitsInt64() (min, max int64)

func (TryteCore[T]) Mul

func (tc TryteCore[T]) Mul(a, b T) (hi, lo T)

func (TryteCore[T]) MulLo

func (tc TryteCore[T]) MulLo(a, b T) (lo T)

func (TryteCore[T]) MustParse

func (tc TryteCore[T]) MustParse(s string) T

func (TryteCore[T]) Neg

func (tc TryteCore[T]) Neg(a T) (b T)

Negative, Invert

func (TryteCore[T]) Parse

func (tc TryteCore[T]) Parse(s string) (T, error)

func (TryteCore[T]) QuoRem

func (tc TryteCore[T]) QuoRem(x, y T) (quo, rem T)

func (TryteCore[T]) Rand

func (tc TryteCore[T]) Rand(r *Rand) T

func (TryteCore[T]) RandSh

func (tc TryteCore[T]) RandSh(r *Rand) T

func (TryteCore[T]) SetAllTrits

func (tc TryteCore[T]) SetAllTrits(t Trit) T

func (TryteCore[T]) Shl

func (tc TryteCore[T]) Shl(a T, i int) T

Shl - shift left a << i

func (TryteCore[T]) Shr

func (tc TryteCore[T]) Shr(a T, i int) T

Shr - shift right a >> i

func (TryteCore[T]) Sign

func (tc TryteCore[T]) Sign(x T) int

func (TryteCore[T]) Sub

func (tc TryteCore[T]) Sub(x, y T, carryIn Trit) (res T, carryOut Trit)

func (TryteCore[T]) ToInt64

func (tc TryteCore[T]) ToInt64(a T) int64

func (TryteCore[T]) TotalTrits

func (tc TryteCore[T]) TotalTrits() int

TotalTrits returns the total number of trits.

func (TryteCore[T]) TryteToInt64

func (tc TryteCore[T]) TryteToInt64(a T, rest int64) (int64, bool)

type UnaryFunc

type UnaryFunc func(Trit) Trit

type Unsigned

type Unsigned = constraints.Unsigned

Unsigned = customUnsigned

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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