Switch to BC math functions

Since the output is now variable, the output can be quite huge, so need to use BC math methods to not overflow.