precision

package
v0.43.2 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2024 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Convert

func Convert(fromPrecision, toPrecision uint32, n *big.Int) *big.Int

Convert is a wrapper of convert function. Use cached `converter` struct if fromPrecision and toPrecision are constant.

Types

type Fixed8Converter

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

Fixed8Converter is a converter with base precision of Fixed8. It uses int64 values because there is a guarantee that balance contract will operate with `Deposit` and `Withdraw` amounts that less than 2**53-1. This is a JSON bound that uses neo node. Neo-go has int64 limit for `smartcontract.Parameter` of integer type.

func NewConverter

func NewConverter(precision uint32) Fixed8Converter

NewConverter returns Fixed8Converter.

func (*Fixed8Converter) SetBalancePrecision

func (c *Fixed8Converter) SetBalancePrecision(precision uint32)

SetBalancePrecision prepares converter to work.

func (Fixed8Converter) ToBalancePrecision

func (c Fixed8Converter) ToBalancePrecision(n int64) int64

ToBalancePrecision converts n of Fixed8 precision to balance contract precision.

func (Fixed8Converter) ToFixed8

func (c Fixed8Converter) ToFixed8(n int64) int64

ToFixed8 converts n of balance contract precision to Fixed8 precision.

Jump to

Keyboard shortcuts

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