MathUtil::Decimal Class
Discussion
When doing numeric calculations with Xbasic there can sometimes be a loss of precision because internally Xbasic uses floating point numbers. The MathUtil::Decimal class can be used for high precision calculations. When using this class, all input numbers and output results are variables of type character (not number).
For example:
Example
? MathUtil::Decimal::Add("1.20","2.30") = "3.50" ? MathUtil::Decimal::Subtract("1.20","2.30") = "-1.10" ? MathUtil::Decimal::Multiply("1.20","2.30") = "2.7600" ? MathUtil::Decimal::Divide("1.20","2.30") = "0.5217391304347826086956521739" ? MathUtil::Decimal::Compare("1.20","2.30") = -1
Methods
- Add Method
Adds two numbers (defined as character strings) together.
- Ceiling Method
Computes the ceiling of the value.
- Compare Method
Compares two values. Returns 0 if they are equal, 1 if the second value is greater, -1 if the first value is greater.
- Divide Method
Divides two specified values.
- Floor Method
Rounds a specified number to the closest integer toward negative infinity.
- Multiply Method
Multiplies two values together.
- Negate Method
Negates the value.
- Remainder Method
Computes the remainder after dividing two values.
- Round Method
Rounds the value to the nearest integer or specified number of decimal places.
- Subtract Method
Subtracts one value from another.
See Also