Non-floating-point fractional exponentiation approach
Completed on 16-Nov-2016 (24 days)

Project 10 in full-screenProject 10 in PDF
Introduction >
Overview

This project explains the calculation methodology which I used to develop NumberParser's Math2.PowDecimal/Math2.SqrtDecimal, methods extending the native double (floating-point) implementations (i.e., Pow/Sqrt in System.Math) to decimal (not floating-point). It is eminently focused on fractional aspects because this is where the floating-point peculiarities are more influential, although there is also an integer exponentiation section.

Microsoft hasn't published the Pow/Sqrt source codes, but they are most likely very similar to equivalent functionalities in other languages or in mathematical libraries. While pre-analysing this whole situation, I took a look at the C library Cephes, which is an interesting reference for anyone looking for insights into all this.

Note that the floating-point peculiarities are precisely meant to efficiently deal with computationally-expensive calculations, what is certainly the case with exponentiation algorithms. Additionally, most of these algorithms are also relying on further assumptions and simplifications, at least for certain scenarios.

In summary, the goal of most of the existing (floating-point-based) exponentiation implementations is delivering reasonably accurate results as quickly as possible. On the other hand, the approach described here is mostly focused on delivering as accurate as possible results reasonably quickly.