Skip to content

vdecimal #

Arbitrary-precision fixed-point decimal numbers

fn decimal_from_int #

fn decimal_from_int(a int) Decimal

decimal_from_int converts an int to Decimal.

fn decimal_from_string #

fn decimal_from_string(value string) !Decimal

decimal_from_string returns a new Decimal from a string representation.
Trailing zeroes are not trimmed.

fn new #

fn new(value i64, exp int) Decimal

new returns a new fixed-point decimal, value * 10 ^ exp.

struct Decimal #

struct Decimal {
	value big.Integer

	exp int
}

Decimal represents a fixed-point decimal.
number = value * 10 ^ exp

fn (Decimal) int_part #

fn (d Decimal) int_part() int

int_part returns the integer component of the decimal.

fn (Decimal) str #

fn (d Decimal) str() string

str returns the string representation of the decimal with the fixed point.
Trailing zeroes in the fractional part are trimmed.

fn (Decimal) + #

fn (decimal Decimal) + (addend Decimal) Decimal

fn (Decimal) - #

fn (decimal Decimal) - (subtrahend Decimal) Decimal

fn (Decimal) * #

fn (decimal Decimal) * (multiplicand Decimal) Decimal

fn (Decimal) == #

fn (a Decimal) == (b Decimal) bool

fn (Decimal) < #

fn (a Decimal) < (b Decimal) bool