@neauoire i'm cheating -- just using a continued fraction representation:
https://git.phial.org/d6/modal/src/branch/d6/binary/arith.modal#L434
i had a GCF implementation using the faster fraction from here: https://en.wikipedia.org/wiki/Generalized_continued_fraction#%CF%80
however the regular CF provides better approximations, so it seemed better to do it that way.