number

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrInvalidRM invalid rounding mode
	ErrInvalidRM = errors.New("invalid rounding mode")
)

Functions

func DecimalFormat

func DecimalFormat(d decimal.Decimal, opts *Options) (formatted string)

DecimalFormat produces a string form of the given decimal.Decimal in base 10

ref: https://github.com/dustin/go-humanize/blob/master/commaf.go#L13

func DecimalRound

func DecimalRound(d decimal.Decimal, opts *Options) (decimal.Decimal, error)

DecimalRound sets d to its value rounded to the given precision using the given rounding mode.

Returns d, which was modified in place.

Types

type Option

type Option interface {
	// contains filtered or unexported methods
}

func WithDecimalPlaces

func WithDecimalPlaces(decimalPlaces uint) Option

func WithDecimalSeparator

func WithDecimalSeparator(decimalSeparator byte) Option

func WithFractionGroupSeparator

func WithFractionGroupSeparator(fractionGroupSeparator byte) Option

func WithFractionGroupSize

func WithFractionGroupSize(fractionGroupSize uint) Option

func WithGroupSeparator

func WithGroupSeparator(groupSeparator byte) Option

func WithGroupSize

func WithGroupSize(groupSize uint) Option

func WithRoundingMode

func WithRoundingMode(mode constants.Rounding) Option

func WithRoundingPrecision

func WithRoundingPrecision(precision int) Option

func WithSecondaryGroupSize

func WithSecondaryGroupSize(secondaryGroupSize uint) Option

type Options

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

func New

func New(opt ...Option) *Options

func (*Options) Apply

func (o *Options) Apply(opt ...Option)

Jump to

Keyboard shortcuts

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