XDecimal and XDecimalHI

Lets you work with floating point values. The XDecimal and XDecimalHI objects are object wrappers for primitive floating point values. XDecimal is appropriate for values that require precision to the hundredths place (2 digits after the decimal point), and XDecimalHI for values that require precision to the ten-thousandths place (4 digits after the decimal point).

Core object

Created by

The XDecimal and XDecimalHI constructors:

new XDecimal( value ) ;
new XDecimalHI( value ) ;

Parameters

Parameter Description
value The floating point value of the object being created.

Description

The primary uses for the XDecimal and XDecimalHI objects are:

  • To perform accurate calculations using floating point values. Because of the nature of the storage of these types of values, mathematical operations require additional logic and checking of results.
  • To perform reliable comparisons of floating point values. Because of the nature of the storage of these types of values, comparison operations require additional logic.

Property Summary

Property Description
constructor Specifies the function that creates an object's prototype.

Method Summary

Method Description
toSource Returns an object literal representing the specified Number object; you can use this value to create a new object. Overrides the Codeparatext method.
toString Returns a string representing the specified object. Overrides the Codeparatext method.
valueOf Returns the primitive value of the specified object. Overrides the Codeparatext method.
to_double Returns a the numeric decimal value.

Examples

Example 1. The following example creates two XDecimal objects, yourNum and myNum, then adds the two together.

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.