godec64

package module
v0.0.0-...-cfc6bed Latest Latest
Warning

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

Go to latest
Published: May 12, 2021 License: LGPL-2.1 Imports: 6 Imported by: 1

README

GoDec64

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

Documentation

Overview

Package to operate on 64-bit decimal fixed point

Package to operate on 64-bit decimal fixed point

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DivFull

func DivFull(hi, lo, b UDec64) (UDec64, UDec64)

func ParseUIntDec

func ParseUIntDec(s string, bits int) (uint64, error)

func ParseUIntDecBytes

func ParseUIntDecBytes(s []byte, bits int) (uint64, error)

Types

type LocFmt

type LocFmt struct {
	Comma, Sep1000, Sep1000_2 rune
	Sep100and1000             bool
	Digits                    []rune
}

locale formatting info

func GetLocFmt

func GetLocFmt(lang string) *LocFmt

get locale formating info

type UDec64

type UDec64 uint64

func Float64ToUDec64

func Float64ToUDec64(a float64, precision uint) (UDec64, error)

convert float64 to UDec128

func Float64ToUDec64R

func Float64ToUDec64R(a float64, precision uint, rounding bool) (UDec64, error)

convert float64 to UDec128

func LocaleParseUDec64

func LocaleParseUDec64(lang, str string, precision uint, rounding bool) (UDec64, error)

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

func LocaleParseUDec64Bytes

func LocaleParseUDec64Bytes(lang string, strInput []byte,
	precision uint, rounding bool) (UDec64, error)

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

func ParseUDec64

func ParseUDec64(str string, precision uint, rounding bool) (UDec64, error)

parse number from string

func ParseUDec64Bytes

func ParseUDec64Bytes(str []byte, precision uint, rounding bool) (UDec64, error)

parse number from bytes

func (UDec64) Convert

func (a UDec64) Convert(srcPrec, destPrec uint, rounding bool) UDec64

func (UDec64) Div

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

func (UDec64) Format

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

format number

func (UDec64) FormatBytes

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

format number to bytes

func (UDec64) FormatNew

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

func (UDec64) FormatNewBytes

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

new format routine with additional displayPrecision argument. Format to bytes

func (UDec64) LocaleFormat

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

func (UDec64) LocaleFormatBytes

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

func (UDec64) LocaleFormatNew

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

format 64-bit decimal fixed point including locale

func (UDec64) LocaleFormatNewBytes

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

format 64-bit decimal fixed point including locale

func (UDec64) Mul

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

func (UDec64) MulFull

func (a UDec64) MulFull(b UDec64) (UDec64, UDec64)

func (UDec64) ToFloat64

func (a UDec64) ToFloat64(precision uint) float64

convert to float64

Jump to

Keyboard shortcuts

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