bits2048

package module
v0.0.0-...-381f378 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2024 License: MIT Imports: 3 Imported by: 0

README

go-bits2048

Package bits2048 implements various 2048-bit types, for the Go programming language.

Documention

Online documentation, which includes examples, can be found at: http://godoc.org/github.com/reiver/go-bits2048

GoDoc

Import

To import package bits2048 use import code like the follownig:

import "github.com/reiver/go-bits2048"

Installation

To install package bits2048 do the following:

GOPROXY=direct go get https://github.com/reiver/go-bits2048

Author

Package bits2048 was written by Charles Iliya Krempeaux

Documentation

Index

Constants

View Source
const (
	ErrOverFlow = erorr.Error("overflow")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type String

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

String is string that can be 0 to 255 bytes long.

String always takes up exactly 256-bytes of space (regarless of how long the string is).

Internally String is a length-prefixed string. This is also sometimes called a “Pascal String”.

Example usage:

var str bits2048.String

str.FromString("Hello world! 🙂")

func FromString

func FromString(value string) (String, error)

FromString returns a bits2048.String from a Go string.

If the Go string is longer than 256-bytes then it returns an error.

func MustFromString

func MustFromString(value string) String

MustFromString returns a bits2048.String from a Go string.

If the Go string is longer than 256-bytes then it panics.

func (*String) Bytes

func (receiver *String) Bytes() []byte

Bytes returns bits2048.String as a Go []byte.

(Note that this does NOT include the length-prefix, onl the string data.)

func (*String) FromString

func (receiver *String) FromString(value string) error

FromString returns a bits2048.String from a Go string.

If the Go string is longer than 256-bytes then it returns an error.

func (String) GoString

func (receiver String) GoString() string

func (*String) Len

func (receiver *String) Len() int

Len returns the length of bits2048.String as the number of bytes.

func (*String) MarshalText

func (receiver *String) MarshalText() (text []byte, err error)

func (*String) String

func (receiver *String) String() string

String returns bits2048.String as a Go string.

func (*String) UnmarshalText

func (receiver *String) UnmarshalText(text []byte) error

type Uint

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

Uint is a 2048-bit unsigned-number.

Uint stores the data as an array of uint. And stores it in little-endian order. So that Uint[0] is the least-significant values, and Uint[31] is the most-significant.

func FromUint64

func FromUint64(value uint64) Uint

FromUint64 returns a bits2048.Uint from a Go uint64.

func FromUint64s

func FromUint64s(values ...uint64) (Uint, error)

func MustFromUint64s

func MustFromUint64s(values ...uint64) Uint

func (*Uint) Add

func (receiver *Uint) Add(src1 *Uint, src2 *Uint) error

func (*Uint) Cmp

func (receiver *Uint) Cmp(other *Uint) int

Cmp compared 'receiver' and 'other', and —

It returns 0 if 'receiver' and 'other' are equal. It return -1 if 'receiver' is less-than 'other'. And it return 1 if 'receiver' is greater-than 'other'.

func (*Uint) FromUint64

func (receiver *Uint) FromUint64(value uint64)

func (*Uint) FromUint64s

func (receiver *Uint) FromUint64s(values ...uint64) error

func (Uint) GoString

func (receiver Uint) GoString() string

Jump to

Keyboard shortcuts

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