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

BigFloat, Decimal, or MPF

Use Decimal when the arithmetic has to be decimal — money, anything whose digits are the point, anything that has to agree with Python’s decimal.Decimal. Use BigFloat for scientific computation at a chosen precision, where binary is the natural base and the question is whether the last bit is right.

MPF, the MPFR-backed float that used to carry the name BigFloat, is still in the source at decimo.mpf.mpf.MPF. It is not exported and carries no promise of a stable interface, and using it means installing MPFR and linking a C wrapper. It is kept as a second implementation to test the traits against, as the baseline the Mojo one is measured against, and for anyone who was relying on it.