godec128

package module
Version: v0.0.0-...-8af96b3 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2021 License: LGPL-2.1 Imports: 6 Imported by: 0

README

GoDec128

Simple library for 128-bit decimal fixed point arithmetic. Pretty simple code to handle 128-bit decimal fixed point values: addition, subtraction, shifts, multiplication, division, parsing and formatting.

Documentation

Overview

Package to operate on 128-bit decimal fixed point

Package to operate on 128-bit decimal fixed point

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type UDec128

type UDec128 goint128.UInt128

func Float64ToUDec128

func Float64ToUDec128(a float64, precision uint) (UDec128, error)

convert float64 to UDec128

func LocaleParseUDec128

func LocaleParseUDec128(lang, str string, precision uint, rounding bool) (UDec128, error)

parse decimal fixed point from string and return value and error (nil if no error)

func LocaleParseUDec128Bytes

func LocaleParseUDec128Bytes(lang string, strInput []byte,
	precision uint, rounding bool) (UDec128, error)

parse decimal fixed point from string and return value and error (nil if no error)

func ParseUDec128

func ParseUDec128(str string, precision uint, rounding bool) (UDec128, error)

parse number from string

func ParseUDec128Bytes

func ParseUDec128Bytes(str []byte, precision uint, rounding bool) (UDec128, error)

parse number from bytes

func UDec128DivFull

func UDec128DivFull(hi, lo, b UDec128) UDec128

fixed point is in 10**(precision*2)

func (UDec128) Add

func (a UDec128) Add(b UDec128) UDec128

add 128-bit decimal fixed points

func (UDec128) Add64

func (a UDec128) Add64(b uint64) UDec128

add 128-bit decimal fixed point and 64-bit fixed decimal point

func (UDec128) AddC

func (a UDec128) AddC(b UDec128, oldCarry uint64) (UDec128, uint64)

add 128-bit decimal fixed points with carry and return sum and output carry

func (UDec128) Cmp

func (a UDec128) Cmp(b UDec128) int

compare 128-bit decimal fixed points and return 0 if they equal, 1 if first is greater than second, or -1 if first is lesser than second

func (UDec128) Div

func (a UDec128) Div(b UDec128, precision uint) UDec128

divide 128-bit decimal fixed points

func (UDec128) Div64

func (a UDec128) Div64(b uint64) UDec128

divide 128-bit unsigned integer by 64-bit unsigned integer

func (UDec128) Format

func (a UDec128) Format(precision uint, trimZeroes bool) string

format number

func (UDec128) FormatBytes

func (a UDec128) FormatBytes(precision uint, trimZeroes bool) []byte

format number to bytes

func (UDec128) FormatNew

func (a UDec128) FormatNew(precision, displayPrecision uint, trimZeroes bool) string

new format routine with additional displayPrecision argument.

func (UDec128) FormatNewBytes

func (a UDec128) FormatNewBytes(precision, displayPrecision uint,
	trimZeroes bool) []byte

new format routine with additional displayPrecision argument. Format to bytes

func (UDec128) IsZero

func (a UDec128) IsZero() bool

return true if zero

func (UDec128) LocaleFormat

func (a UDec128) LocaleFormat(lang string, precision uint,
	trimZeroes, noSep1000 bool) string

func (UDec128) LocaleFormatBytes

func (a UDec128) LocaleFormatBytes(lang string, precision uint,
	trimZeroes, noSep1000 bool) []byte

func (UDec128) LocaleFormatNew

func (a UDec128) LocaleFormatNew(lang string, precision, displayPrecision uint,
	trimZeroes, noSep1000 bool) string

format 128-bit decimal fixed point including locale

func (UDec128) LocaleFormatNewBytes

func (a UDec128) LocaleFormatNewBytes(lang string, precision, displayPrecision uint,
	trimZeroes, noSep1000 bool) []byte

format 128-bit decimal fixed point including locale

func (UDec128) Mul

func (a UDec128) Mul(b UDec128, precision uint, rounding bool) UDec128

multiply 128-bit decimal fixed points and return lower 128 bits value

func (UDec128) Mul64

func (a UDec128) Mul64(b uint64) UDec128

multiply 128-bit decimal fixed point and 64-bit unsigned integer and return lower 128 bits product

func (UDec128) MulFull

func (a UDec128) MulFull(b UDec128) (UDec128, UDec128)

multiply 128-bit decimal fixed point and return high and lower product integer part is multiplied by 10**precision

func (UDec128) Shl

func (a UDec128) Shl(b uint) UDec128

shift 128-bit decimal fixed point left by b bits

func (UDec128) Shr

func (a UDec128) Shr(b uint) UDec128

shift 128-bit decimal fixed point right by b bits

func (UDec128) Sub

func (a UDec128) Sub(b UDec128) UDec128

subtract 128-bit decimal fixed points

func (UDec128) Sub64

func (a UDec128) Sub64(b uint64) UDec128

subtract 128-bit decimal fixed point and 64-bit fixed decimal point

func (UDec128) SubB

func (a UDec128) SubB(b UDec128, oldBorrow uint64) (UDec128, uint64)

subtract 128-bit decimal fixed points with borrow and return difference and borrow

func (UDec128) ToFloat64

func (a UDec128) ToFloat64(precision uint) float64

convert to float64

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL