-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A possible bug in Text.Parsec.Token.float #35
Comments
I'm sorry that I have to repeat myself, but this is an obvious bug. Will I it be ignored? If you're not willing to notice or fix it, will you accept pull request that fixes it? |
I'm always curious when some open source/free software maintainer ignores an obvious bug. I always start to think why would any conscious person behave like this. At any rate, you could just drop a couple of lines, for example:
or something. But in this case, it's an obvious bug (so first option is not applicable) and it must be fixed. It can lead to situations when floating point data is read and parsed incorrectly by Parsec and who knows what consequences it can cause in production. So, I urge you, please consider fixing this bug, or at least giving us your opinion here. If you do not have time to fix this bug, we are here to help you! |
I think it's a bug as well. I find the second answer, the one from Reid Barton, is easier to understand. |
Sorry for the radio silence on this ticket - I think it would be reasonable for Parsec to give similar behavior to |
@aslatter, OK, I will try to find time and fix it. Also, I will add |
Interestingly, |
I think it's also a bug.
I'm adding new test cases to test this too. |
Here is new test case, I don't have time right now to proceed to fix it, but this contribution should be useful as well. |
@aslatter I totally with you on that "parsec shall be consistent with
We could see that the two are not consistent:
|
@mrkkrp As the negative floating numbers, I looked up the def in haskell report 2010; the corresponding section doesn't say anything about negative literals, and it refers to section 3.4 for negative number literals. After reading it, I think it makes sense to only parse number without
|
@albertnetymk, Now I think that |
Backward compatibility is a big concern. I am just bringing it up so that this change could be added to match the haskell report in the future backward incompatible release, maybe parsec 4? |
Well, I think it's up to the maintainer to decide. |
After a little research I conclude that it's impossible to re-create floating point number without losing precision by means of floating point arithmetic, since it has fixed precision and result will be always incorrect. See this for more information: http://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html The only way to recreate floating point number is by careful manipulations on bit-level. This brings us to the dilemma:
This problem is not trivial. Complex C libraries on OS level usually do such sort of thing, and high-level languages use such libraries. See also this SO questions and answers for more information: http://stackoverflow.com/questions/85223/how-to-manually-parse-a-floating-point-number-from-a-string |
The first approach could be brittle, for in order to keep |
@albertnetymk, if you're still interested in Parsec, I've created a fork of the project called megaparsec. I've changed many things already, but all that work is preparatory. I've removed many compatibility things and improved documentation (typos, code examples, it's 100% covered now), also I've reworked about 70% of original code-base, mainly for cosmetic reasons. Now I'm simply going to fix all the issues that are hanging here for a start, after that I will build complete QuickCheck test suite. If you're interested please propose changes. I'll probably remove |
@mrkkrp Excellent work. I would watch the new repo. |
Suppress hsc2hs-related warning on GHC HEAD
There may be a bug in
Text.Parsec.Token.float
. Please see this SO question for comprehensive description:http://stackoverflow.com/questions/29820870/floating-point-numbers-precision-and-parsec
The text was updated successfully, but these errors were encountered: