-
Notifications
You must be signed in to change notification settings - Fork 197
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Unclear expected values for integer division #1096
Comments
To be honest, I don't see that big of a difference — it merely checks out two use cases (positive and negative) times two sources (constant or value coming from a file). But, well, |
The question what is expected results for |
Sometimes I can't decode what you mean by your sentences - is that your question? Did you not see the comment at the top of the KSY spec # Tests division operation, both positive and negative
# See https://github.com/kaitai-io/kaitai_struct/issues/746
# => the KS division operation `a / b` should do `floor(a / b)` I think this states the expected behavior clear enough and it even provides a link to #746 with detailed explanation.
Hypothetically, it probably could if the corresponding translator method of some target in KSC was implemented by someone who doesn't know the correct semantics, but as far as I know, it doesn't in any target language at the moment (i.e.
This sounds like the table @dgelessus made (the columns to look at would be
As @GreyCat said, feel free to improve the test as you see fit, at least we'll have something concrete to discuss. |
Yes, strangely, but it is true. I really didn't notice it. The investigation in #746, however, somehow ignored the issue with a negative divisor. Also for me it is strange that as the test use of strange numbers which result of division it is heavy to calculate manually and that only couple of values from all (incomplete) described table are checked was chosen. I'll prepare PR with exhaustive tests soon. I only hope that it will not stuck as other my (and not only my) PRs here. |
Currently Java test
tests\formats\expr_int_div.ksy
is failed with the following message:I suggest instead of testing strange numbers just test division of everything in range [-10; 10] by 3 and -3, the same for
mod
.The text was updated successfully, but these errors were encountered: