-
-
Notifications
You must be signed in to change notification settings - Fork 53
Skip incomplete parts of numbers #226
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
Conversation
@sebastienros A number like "123." should be treated as "123". It sort of is, however, parsing fails. Why? Let's look at this code in the ReadDecimal method:
The parser has read "123" and got into this block. The number is not empty, but there is no number after a decimal separator. So, the reader resets the cursor position to before the decimal separator and returns "123". The separator in this situation must be consumed, so that the consequent scanning works properly. With current code, multiple NCalc tests fail. This is for this reason, I did not include any checks to the decimal separator part in my pull request (I only modified the part related to group separators). The following change fixes the problem:
|
Ok, so we need to assume that when And |
Yes. This is because a number cannot end with a group separator, but it can end with a decimal separator (in some countries, it is a popular form).
I am not sure about this one. As I mentioned elsewhere, I have not found such a notation for scientific numbers. So I assume that you nailed it - consume 123 with a dot and return just a number 123, leaving "e" for another parser. But maybe someone comes out and says "in my university we write 123.e2 all the time" :). |
Then let's say that if the exponent is defined in options |
Applying this idea