Copyright | (c) Jun Narumi 2018 |
---|---|
License | BSD3 |
Maintainer | narumij@gmail.com |
Stability | experimental |
Portability | ? |
Safe Haskell | Safe |
Language | Haskell2010 |
Floating point parser
Temporary solution to the problem below
ghci> realToFrac (read "1.1" :: Double) :: Rational 2476979795053773 % 2251799813685248
- readFloatingPoint :: Integral a => String -> Ratio a
- floating :: Integral a => CharParser () (Ratio a)
Documentation
readFloatingPoint :: Integral a => String -> Ratio a Source #
Obtain fractions from floating point representation string
>>>
readFloatingPoint "1.1"
11 % 10>>>
readFloatingPoint "0.5"
1 % 2>>>
readFloatingPoint ".5"
1 % 2>>>
readFloatingPoint "10."
10 % 1>>>
readFloatingPoint "10"
10 % 1>>>
readFloatingPoint "10.2"
51 % 5>>>
readFloatingPoint "1e-1"
1 % 10>>>
readFloatingPoint "-0.5e-1"
(-1) % 20>>>
readFloatingPoint "5e2"
500 % 1>>>
readFloatingPoint "5e+2"
500 % 1