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.

struct Decimal (
Hook = Abort
) {}

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.
clamped
bool clamped()
divisionByZero
bool divisionByZero()

Exceptional condition flags

dup
Decimal!(Hook) dup()
idup
immutable(Decimal!(Hook)) idup()
inexact
bool inexact()
invalidOperation
bool invalidOperation()
isInf
bool isInf()
isNan
bool isNan()

Exceptional condition flags

opAssign
auto opAssign(T num)

Changes the value of this decimal to the value of a built-in number. Also resets all exceptional condition flags.

opBinary
auto opBinary(T rhs)

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

opCast
auto opCast()
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.

overflow
bool overflow()

Exceptional condition flags

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.
rounded
bool rounded()

Exceptional condition flags

sign
bool sign()
subnormal
bool subnormal()

Exceptional condition flags

toDecimalString
auto toDecimalString()
void toDecimalString(Writer w)
underflow
bool underflow()

Exceptional condition flags

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.

Properties

clamped
bool clamped [@property setter]
Undocumented in source. Be warned that the author may not have intended to support it.
divisionByZero
bool divisionByZero [@property setter]
Undocumented in source. Be warned that the author may not have intended to support it.
inexact
bool inexact [@property setter]
Undocumented in source. Be warned that the author may not have intended to support it.
invalidOperation
bool invalidOperation [@property setter]
Undocumented in source. Be warned that the author may not have intended to support it.
isInf
bool isInf [@property setter]
Undocumented in source. Be warned that the author may not have intended to support it.
isNan
bool isNan [@property setter]
Undocumented in source. Be warned that the author may not have intended to support it.
overflow
bool overflow [@property setter]
Undocumented in source. Be warned that the author may not have intended to support it.
rounded
bool rounded [@property setter]
Undocumented in source. Be warned that the author may not have intended to support it.
sign
bool sign [@property setter]
Undocumented in source. Be warned that the author may not have intended to support it.
subnormal
bool subnormal [@property setter]
Undocumented in source. Be warned that the author may not have intended to support it.
underflow
bool underflow [@property setter]
Undocumented in source. Be warned that the author may not have intended to support it.

Static functions

infinity
Decimal!(Hook) infinity()
max
Decimal!(Hook) max()
min
Decimal!(Hook) min()
nan
Decimal!(Hook) nan()

Variables

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

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

maxExponent
enum int maxExponent;
Undocumented in source.
maxExponent
enum int maxExponent;
Undocumented in source.
minExponent
enum int minExponent;
Undocumented in source.
minExponent
enum int minExponent;
Undocumented in source.
precision
enum uint precision;
Undocumented in source.
precision
enum uint precision;
Undocumented in source.
roundingMode
enum Rounding roundingMode;
Undocumented in source.
roundingMode
enum Rounding roundingMode;
Undocumented in source.

Meta