To read an integer written in decimal form is quite simple :
Prelude> read "1000000000" :: Int
1000000000
But how to read an integer written in exponetial form ?
Prelude> read "10e+9" :: Int
*** Exception: Prelude.read: no parse
Is there a function in the Prelude to do that, or do we need to parse the expression?
Thanks for any reply.
Depending on the exact format of the string, you could just
readit into a floating point type:then convert to an integral type — I’d recommend
Integerinstead ofInt: