XFloat Documentation - 4. Conversion Operations

Written by Integralus

4. Conversion Operations

  • .toNumber()

    Return conversion of current object to built-in floating-point type

    If current object has more than 3 word of precision, only an approximation of the upper 53 bits is returned.

  • .toDecimal([precision])

    • precision: (24-bit integer) the number of word below decimal point to convert

    Return conversion of current object to a string in decimal. The precision below decimal point is decided by precision. If precision is 0, only an integer part is returned. If precision is increased by 1, the precision below decimal point would be increased by 7 digit. If precision is omitted, the precision is decided according to a length of mantissa in current object.

  • .fromDecimal(string[, precision])

    • string: (String) the string representing decimal number to be converted into XFloat object
    • precision: (24-bit integer) the number of word below decimal point

    Store conversion of string representing decimal number in current XFloat object. The precision below decimal point is decided by precision. If precision is 0, only an integer part will be stored. If precision is increased by 1, the precision below decimal point would be increased by 7 digit. If precision is omitted, the precision is decided according to the number of digit below decimal point in string.

    This method returns 'this'.

Conversion Example

Other languages