Integralus' Math Story

2. XFloat Basics

Here describes the basic concepts you need to know to before using XFloat.

Word

XFloat split a large integer into 24-bit size internally. This 24-bit unit is called 'word'. Thus one word matches a 24-bit integer. Numeric expressed in XFloat can be stored in one word or more, depending on the precision of that number.

Floating-point

Floating point stores numbers into the mantissa and exponent parts. Thus, representing the number of 12,340,000 in floating point is 1, 2, 3, 4 and 7 because 12,340,000 = 1.234 * 107, instead of storing all digits like 1,2,3,4,0,0,0,0.

In IEEE 754 floating-point format, double-precision can not exceed 53-bit precision. Therefore, the error will occur in the lower-digit if more than 53-bit of precision is required to store the value. In XFloat, however, the precision of mantissa is adjusted as needed, so you can lower the error of the value below a desired.

Sign

XFloat, as distinct from IEEE 754 format, handles a sign of value into three. One is positive (greater than 0), another is 0, and the other is negative (smaller than 0). Thus, XFloat has unique 0 value while IEEE 754 divides zero into +0 and -0.

Exception

In IEEE 754 format, the result is set to Infinity or NaN if an exception, such as dividing by zero and square root of a negative number, is occured. In contrast, XFloatError object is thrown as an exception when unrecoverable error is occurred in XFloat. So you need to write a routine to handle an exception occurred in operations.