fix pointing number parsing
This commit is contained in:
parent
107f887147
commit
ff5197de5c
1 changed files with 6 additions and 5 deletions
11
src/Lib.hs
11
src/Lib.hs
|
@ -64,13 +64,14 @@ constantInteger = try (do
|
|||
|
||||
constantRational :: Parser Rational
|
||||
constantRational = do
|
||||
natural <- m_natural
|
||||
_ <- char '.'
|
||||
decimal <- m_natural
|
||||
natural <- m_natural
|
||||
_ <- char '.'
|
||||
decimal_digits <- many digit
|
||||
let decimal = read decimal_digits :: Integer
|
||||
let natural_length = length . show $ natural
|
||||
let decimal_length = length . show $ decimal
|
||||
let decimal_length = length decimal_digits
|
||||
let numerator = natural * (10 ^ decimal_length) + decimal
|
||||
let denominator = 10 ^ (decimal_length + natural_length - 2)
|
||||
let denominator = 10 ^ (decimal_length + natural_length - 1)
|
||||
return (numerator % denominator)
|
||||
|
||||
{-
|
||||
|
|
Loading…
Reference in a new issue