toIntegral :: (Num a) => Scientific -> a
toIntegral (Scientific c e) = fromInteger c * fromInteger (magnitude e)
This has the unsafe fromInteger (magnitude e) operation which can fill up all space and crash your program.
This didn't use to be the case. In the past magnitude :: (Num a) => Int -> a so the resulting value was represented in the target type (for example Int) which could be bounded in size which means no space blowup.
round
and the otherRealFrac
methods use:This has the unsafe
fromInteger (magnitude e)
operation which can fill up all space and crash your program.This didn't use to be the case. In the past
magnitude :: (Num a) => Int -> a
so the resulting value was represented in the target type (for exampleInt
) which could be bounded in size which means no space blowup.I changed this in https://github.com/basvandijk/scientific/commit/7d1859bee6c2a2fb24fa636d42a580de67b13095#diff-f161ee633ba321f16b84ed96bcc15e4eL596 which I now realize was a mistake.
Lets fix this.