mathr / blog / #

Floating point with extended exponent range

Some time ago I implemented a small library to extend floating point types with a larger exponent, so that you can represent really huge or really tiny numbers without overflow to infinity or underflow to zero. Now that compensated is updated on Hackage, I released it this morning.

> unExpExtended . log . exp . expExtended' $ 1000
1000.0
>                 log . exp                $ 1000
Infinity
> unExpExtended . log . exp . negate . expExtended' $ 1000
-1000.0
>                 log . exp . negate                $ 1000
-Infinity

Or replace uses of the Double type with the EDouble type. If using with compensated, use Compensated EDouble rather than trying to ExpExtend Compensated Double, otherwise you'll be limited to 1000 or so bits as the least-significant limbs will underflow to zero.