fix pointing number parsing
This commit is contained in:
parent
107f887147
commit
ff5197de5c
1 changed files with 6 additions and 5 deletions
|
@ -66,11 +66,12 @@ constantRational :: Parser Rational
|
||||||
constantRational = do
|
constantRational = do
|
||||||
natural <- m_natural
|
natural <- m_natural
|
||||||
_ <- char '.'
|
_ <- char '.'
|
||||||
decimal <- m_natural
|
decimal_digits <- many digit
|
||||||
|
let decimal = read decimal_digits :: Integer
|
||||||
let natural_length = length . show $ natural
|
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 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)
|
return (numerator % denominator)
|
||||||
|
|
||||||
{-
|
{-
|
||||||
|
|
Loading…
Reference in a new issue