Haskell-Decimal
Haskell-Decimal copied to clipboard
Prelude.read: no parse error for numbers with more than 255 decimal places
Doing a read of a number with more than 255 decimal places i.e.
read("12.3333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333") :: Decimal
(256 decimal places)
Causes the following error:
*** Exception: Prelude.read: no parse
Decimal uses a Word8 (i.e. 8 bits) to store the exponent, so this is the Right Thing. A note in the documentation might be a good idea though.
Maybe we could do a function before doing readDecimalP
. Something like
get255Decimals :: String -> String
get255Decimals ('.' : xs) = "." ++ (take 255 xs)
get255Decimals (x : xs) = [x] ++ (get255Decimals xs)
could do the job.