Decimal
struct Decimal
Returns a new Decimal number with the specified number of decimal points for fractional portion. Rounding currently follows “Bankers Rounding” rules. e.g. 6.5 -> 6, 7.5 -> 8
Returns a new Decimal number with the specified number of decimal points for fractional portion. Rounding currently follows “Bankers Rounding” rules. e.g. 6.5 -> 6, 7.5 -> 8
Returns a new Decimal number with the specified number of decimal points for fractional portion. Rounding currently follows “Bankers Rounding” rules. e.g. 6.5 -> 6, 7.5 -> 8
Returns the minimum of the two numbers.
Returns the minimum of the two numbers.
Returns the minimum of the two numbers.
Returns the maximum of the two numbers.
Returns the maximum of the two numbers.
Returns the maximum of the two numbers.
Returns true if the decimal number is equivalent to zero.
Returns true if the decimal number is equivalent to zero.
Returns true if the decimal number is equivalent to zero.
is_sign_positive
pub fn is_sign_positive(self): bool
Returns true
if the sign bit of the decimal is positive.
is_sign_positive
pub fn is_sign_positive(self): bool
Returns true
if the sign bit of the decimal is positive.
Returns true
if the sign bit of the decimal is positive.
is_sign_negative
pub fn is_sign_negative(self): bool
Returns true
if the sign bit of the decimal is negative.
is_sign_negative
pub fn is_sign_negative(self): bool
Returns true
if the sign bit of the decimal is negative.
Returns true
if the sign bit of the decimal is negative.
is_integer
pub fn is_integer(self): bool
Returns true
if the decimal number has zero fractional part (is equal to an integer)
is_integer
pub fn is_integer(self): bool
Returns true
if the decimal number has zero fractional part (is equal to an integer)
Returns true
if the decimal number has zero fractional part (is equal to an integer)
Returns a new decimal integral with no fractional portion. This is a true truncation whereby no rounding is performed.
Returns a new decimal integral with no fractional portion. This is a true truncation whereby no rounding is performed.
Returns a new decimal integral with no fractional portion. This is a true truncation whereby no rounding is performed.
Strips any trailing zero's from a decimal and converts -0
to 0
.
Strips any trailing zero's from a decimal and converts -0
to 0
.
Strips any trailing zero's from a decimal and converts -0
to 0
.
Returns a new decimal representing the fractional portion of the number.
Returns a new decimal representing the fractional portion of the number.
Returns a new decimal representing the fractional portion of the number.
Returns the largest integer less than or equal to a number.
Returns the largest integer less than or equal to a number.
Returns the largest integer less than or equal to a number.
Returns the smallest integer greater than or equal to a number.
Returns the smallest integer greater than or equal to a number.
Returns the smallest integer greater than or equal to a number.
operator-:1
pub fn operator-:1(self): Decimal
operator-:1
pub fn operator-:1(self): Decimal
operator%:2
pub fn operator%:2(self, b: Decimal): Decimal
operator%:2
pub fn operator%:2(self, b: Decimal): Decimal
operator/:2
pub fn operator/:2(self, b: Decimal): Decimal
operator/:2
pub fn operator/:2(self, b: Decimal): Decimal
operator*:2
pub fn operator*:2(self, b: Decimal): Decimal
operator*:2
pub fn operator*:2(self, b: Decimal): Decimal
operator-:2
pub fn operator-:2(self, b: Decimal): Decimal
operator-:2
pub fn operator-:2(self, b: Decimal): Decimal
operator+:2
pub fn operator+:2(self, b: Decimal): Decimal
operator+:2
pub fn operator+:2(self, b: Decimal): Decimal
operator<=:2
pub fn operator<=:2(self, b: Decimal): bool
operator<=:2
pub fn operator<=:2(self, b: Decimal): bool
operator<:2
pub fn operator<:2(self, b: Decimal): bool
operator<:2
pub fn operator<:2(self, b: Decimal): bool
operator>=:2
pub fn operator>=:2(self, b: Decimal): bool
operator>=:2
pub fn operator>=:2(self, b: Decimal): bool
operator>:2
pub fn operator>:2(self, b: Decimal): bool
operator>:2
pub fn operator>:2(self, b: Decimal): bool
operator!=:2
pub fn operator!=:2(self, b: Decimal): bool
operator!=:2
pub fn operator!=:2(self, b: Decimal): bool
operator==:2
pub fn operator==:2(self, b: Decimal): bool
operator==:2
pub fn operator==:2(self, b: Decimal): bool
to_float
pub fn to_float(self): float throws DecimalError
to_float
pub fn to_float(self): float throws DecimalError
to_int
pub fn to_int(self): int throws DecimalError
to_int
pub fn to_int(self): int throws DecimalError
parse
pub fn parse(value: string, radix: int = 10): Decimal throws DecimalError
Parse a string
to decimal
.
parse
pub fn parse(value: string, radix: int = 10): Decimal throws DecimalError
Parse a string
to decimal
.
Parse a string
to decimal
.
If the string is a valid decimal, return decimal value, else raise DecimalError
.
The radix
is the base of the number, default is 10
.
let n = try! Decimal.parse("123.456");
assert_eq n.to_string(), "123.456";
let n = try! Decimal.parse("123.456", radix: 16);
assert_eq n.to_string(), "1193.046";
from_float
pub fn from_float(value: float): Decimal throws DecimalError
from_float
pub fn from_float(value: float): Decimal throws DecimalError