So, I recently started using the scientific package because it provides arbitrary precision numbers through Data.Scientific
which I haven't seen anywhere else. One issue that I've run into is the divergence of division /
(which is indeed warned about in the documentation) when property testing my code with QuickCheck. I'm using the Arbitrary
instance from quickcheck-instances.
I don't have very much formal (read: none) experience with scientific computing so I was wondering if there is any best practices for handling this case. Is there some decent algorithm for performing this operation with possibly a small loss of precision or some way of detecting this ahead of time and returning Nothing
or something equivalent when the result would be ill-defined.
Alternatively, (not as ideal) can I just exclude numbers with infinite decimal expansions from my QuickCheck tests so they don't hang forever? This obviously has the downside that it only treats the symptom and a user of the code could still cause divergence if they passed in "bad" data.
Any suggestions would be greatly appreciated :)