cmditch / elm-bigint

An elm implementation of the BigInt paradigm.
MIT License
15 stars 4 forks source link

Incorrect parsing at fromString #1

Closed decafbad closed 5 years ago

decafbad commented 5 years ago

Output of fromString "--2" is Just (Neg (Magnitude [-2]))

Then, this happens:

Maybe.map (mul (fromInt -3)) (fromString "--2") |> Maybe.map toString Just "-19999994"

cmditch commented 5 years ago

Good catch.

I'm inclined to treat "--2" as invalid. Can you provide any reasons for why "--" might be a useful pattern?

Thanks

decafbad commented 5 years ago

I was working on a Fraction library based on this one. My own bug raised this problem. All kinds of malformed string should return Nothing anyways.

cmditch commented 5 years ago

Gonna re-open this, as I am working on a fix.

cmditch commented 5 years ago

Finally fixed 👍 https://github.com/cmditch/elm-bigint/commit/e2350f4be81d3ecec81632d9d352aad28b218d92