Note: The code contains a custom implementation of ldexp in python, because on Windows (below Win 11) ldexp is broken and rounds denormals incorrectly. ldexp is used by mpmath to convert multi-precision to float, which led to incorrect floating point results (specifically denormals).