Decimal

A exact decimal type, accurate to Hook.precision digits. Designed to be a drop in replacement for floating points.

Behavior is defined by Hook. See the module overview for more information.

Constructors

this
this(T num)

Constructs an exact decimal type from a built in number

this
this(S str)

Converts a string representing a number to an exact decimal.

Members

Aliases

hook
alias hook = Hook
Undocumented in source.
toString
alias toString = toDecimalString

Functions

addImpl
Decimal!(Hook) addImpl(T rhs)
Undocumented in source. Be warned that the author may not have intended to support it.
dup
Decimal!(Hook) dup()
idup
immutable(Decimal!(Hook)) idup()
opBinary
auto opBinary(T rhs)

Performs a binary operation between two decimals, or a decimal and a built in number.

opCast
auto opCast()

For bool, follows the normal cast(bool) rules for floats in D. Numbers <= -1 returns true, numbers between -1 and 1 return false, numbers >= 1 return true.

opCmp
int opCmp(T d)

-Infinity is less than all numbers, -NaN is greater than -Infinity but less than all other numbers, NaN is greater than -NaN but less than all other numbers and Infinity is greater than all numbers. -NaN and NaN are equal to themselves.

opEquals
bool opEquals(T d)
opOpAssign
Decimal!(Hook) opOpAssign(T rhs)

Performs a binary operation between two decimals, or a decimal and a built in number.

opUnary
auto opUnary()
opUnary
Decimal!(Hook) opUnary()

Modifies the decimal in place by adding or subtracting 1 for ++ and -- respectively.

resetFlags
void resetFlags()

Convenience function to reset all exceptional condition flags to false at once

round
auto round(T num)
Undocumented in source. Be warned that the author may not have intended to support it.
toDecimalString
auto toDecimalString()
void toDecimalString(Writer w)

Manifest constants

hasClampedMethod
enum hasClampedMethod;
Undocumented in source.
hasDivisionByZeroMethod
enum hasDivisionByZeroMethod;
Undocumented in source.
hasInexactMethod
enum hasInexactMethod;
Undocumented in source.
hasInvalidOperationMethod
enum hasInvalidOperationMethod;
Undocumented in source.
hasOverflowMethod
enum hasOverflowMethod;
Undocumented in source.
hasRoundedMethod
enum hasRoundedMethod;
Undocumented in source.
hasSubnormalMethod
enum hasSubnormalMethod;
Undocumented in source.
hasUnderflowMethod
enum hasUnderflowMethod;
Undocumented in source.
useBigInt
enum useBigInt;
Undocumented in source.
useBigInt
enum useBigInt;
Undocumented in source.
useU128
enum useU128;
Undocumented in source.
useU128
enum useU128;
Undocumented in source.

Static functions

infinity
Decimal!(Hook) infinity()
nan
Decimal!(Hook) nan()

Variables

clamped
bool clamped;

Public flags

coefficient
BigInt coefficient;
Undocumented in source.
coefficient
uint128 coefficient;
Undocumented in source.
coefficient
ulong coefficient;
Undocumented in source.
divisionByZero
bool divisionByZero;

Public flags

exponent
int exponent;
Undocumented in source.
hook
Hook hook;

hook is a member variable if it has state, or an alias for Hook otherwise.

inexact
bool inexact;
invalidOperation
bool invalidOperation;

Public flags

isInf
bool isInf;
Undocumented in source.
isNan
bool isNan;
Undocumented in source.
overflow
bool overflow;
rounded
bool rounded;

Public flags

sign
bool sign;
Undocumented in source.
subnormal
bool subnormal;
underflow
bool underflow;

Public flags

Meta