fix pointing number parsing

This commit is contained in:
VegOwOtenks 2024-09-15 17:06:40 +02:00
parent 107f887147
commit ff5197de5c

View file

@ -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)
{-