You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried a single 67-bit input and got similar results. It's using floor. Of course with positive arguments they're all identical.
I just added left and right integer shifting to Math::Prime::Util, with two versions of right shifting (one truncating which matches Pari and Mathematica, and one flooring which matches most programming languages). I can see decent arguments for either one, so honestly I don't have any strong opinions on whether one is better than another. But it's important to document and be consistent.
The text was updated successfully, but these errors were encountered:
From the above examples, Sidef matches Perl and Julia regarding integer-division (doing truncated division), while the right-shift is doing floor-division in all examples, except for PARI/GP.
There are some pros for integer division to mean floor(a/b) instead of int(a/b), mainly because the floor-division is more useful in mathematics than truncated-division and is also used in more mathematical formulas, like: a mod b = a - b*floor(a/b):
Thanks for reporting the issue. I will fix the documentation and, I think, I will also change the behavior of a // b to do floor-division instead of truncated-division.
The documentation in lib/Sidef/Types/Number/Number.pod says:
which looks like truncated division. It seems to do a floor division instead. E.g. from the Sidef online system (btw, awesome!):
I tried a single 67-bit input and got similar results. It's using floor. Of course with positive arguments they're all identical.
I just added left and right integer shifting to Math::Prime::Util, with two versions of right shifting (one truncating which matches Pari and Mathematica, and one flooring which matches most programming languages). I can see decent arguments for either one, so honestly I don't have any strong opinions on whether one is better than another. But it's important to document and be consistent.
The text was updated successfully, but these errors were encountered: