Precision aware Decimal implementation. Any size number with any number of significant digits is supported.

Note that operations are precision aware operations. Note that whole numbers are assumed to have unlimited precision. For example:

  2 x 2 = 4
  2.0 x 2.0 = 4.0
  2.00 x 2.0 = 4.0
and
 10 / 3 = 3.33333333333333333333333333333333333333333333333
 10.0 / 3 = 3.33
 10.00 / 3 = 3.333
 10.00 / 3.0 = 3.3
 10 / 3.0 = 3.3

Addition

  2 + 0.001 = 2.001
  2.0 + 0.001 = 2.0

Note that the string representation is precision limited, but the internal representation is not.

why QDecimal as a name in the DotNet API? It's for quantities, but just calling it Decimal clashes with System.Decimal which is always in scope

Properties

bool IsScientific;
   whether to use a scientific representation (i.e. 1e10). This value is carried across operations

int Precision;
   the precision of the value. You can change the precision if you want.

string AsString;
   String representation of the value - will use scientific or decimal notation as specified by the IsScientific property

string AsScientific;
   String representation using scientific notiation

string AsDecimal;
   String representation using decimal notiation


Methods

bool IsZero();
   true if this value is zero (also implies isWholeNumber = true)

bool IsOne();
   true if this value is zero (also implies isWholeNumber = true)

bool IsWholeNumber();
   true if this value is a whole number

HL7Connect.Ucum.QDecimal Trunc();
   retrun this number with any decimal places removed

HL7Connect.Ucum.QDecimal Multiply(HL7Connect.Ucum.QDecimal oOther);
   return this value multiplied by other value.

HL7Connect.Ucum.QDecimal Divide(HL7Connect.Ucum.QDecimal oOther);
   return this value divided by other value.

HL7Connect.Ucum.QDecimal DivInt(HL7Connect.Ucum.QDecimal oOther);
   return the number of times other will "fit into" this number. This is usually called Integer Division, but in this implementation, neither this nor other needs to be a whole number; however the result of this operation will always be a whole number

HL7Connect.Ucum.QDecimal Modulo(HL7Connect.Ucum.QDecimal oOther);
   modulus - the left over when fitting other into this.

this modulo other = this - (other * (this divint other))

HL7Connect.Ucum.QDecimal Add(HL7Connect.Ucum.QDecimal oOther);
   return the result of adding this to other

HL7Connect.Ucum.QDecimal Subtract(HL7Connect.Ucum.QDecimal oOther);
   return the result of subtracting other from this

decimal AsCOMDecimal();
   Represent the decimal in the native COM decimal format. Precision is lost in this representation.

long AsInt64();
   Represent the decimal as a simple int 64, if possible.

string AsHex(int chars);
   Represent the decimal as a hex value - if it is a whole number.


© Kestral Computing P/L 2000 - 2003. HL7Connect v2.00-063 generated on 30-Nov 2015.
Keywords: AsString, Add, Precision, AsCOMDecimal, AsDecimal, AsHex, AsInt64, AsScientific, Divide, DivInt, IsOne, IsScientific, IsWholeNumber, IsZero, Modulo, Multiply, Subtract, Trunc, HL7Connect.Ucum.QDecimal, QDecimal