Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Special Values (BigFloat)

The special values follow IEEE 754 rather than Decimal’s rules, because this is a float:

from decimo.bigfloat.trigonometric import arctan

print(sqrt(BigFloat.from_int(-4), 53).is_nan())      # True, not an error
print(ln(BigFloat.zero(), 53))                        # -Infinity
print(sin(BigFloat.infinity(), 53).is_nan())          # True: it settles nowhere
print(arctan(BigFloat.infinity(), 53))                # pi/2: this one settles

A NaN is unordered, so every comparison with it is False except !=, and that holds for a NaN against itself. The two zeros compare equal. Sorting therefore needs an order that covers them, and compare_total() is it: it runs from -Infinity up to the NaN and separates values that are numerically equal by their precision.

There is no overflow to an infinity for a finite argument. The exponent is as wide as an Int, so an operation that asks for more — exp of anything from about 6.4e18 up — raises rather than returning an infinity it did not earn.