-
Notifications
You must be signed in to change notification settings - Fork 57
Sign of result of "remainder" #84
Comments
Yes, this should have semantics similar to the |
Because of the matter of the sign, Scheme distinguishes between "remainder" and "modulo" and provides standard procedures for both: http://www.schemers.org/Documents/Standards/R5RS/HTML/r5rs-Z-H-2.html#%_toc_%_sec_6.2.5. I suggest you do the same. |
@lars-t-hansen We discussed this in #37 . It seems that % is neither modulo nor remainder, if I understand correctly. Name suggestions are welcome! |
It might be useful to provide correct (in the number-theoretic sense) remainder and modulo operations, then, since BigInt is an integer type. (Presumably as static methods.) |
@lars-t-hansen Seems not so hard for a user to implement out of % and a few conditionals, right? Would it be OK to leave this for v2? |
The proposal currently reads:
where "modulo" links to https://tc39.github.io/ecma262/#sec-algorithm-conventions (side note: that should be https://tc39.github.io/ecma262/#sec-mathematical-operations instead), which says (emphasis mine):
This is notably different from the % operator, which says:
I would assume that
%
on BigInts should mirror the behavior for integer-valued Numbers. Having differing behavior would be quite surprising, I think:(I don't think this is a bug in the existing spec; modulo is mostly used with positive powers of two as the right-hand side there, where ToUint behavior is desired.)
The text was updated successfully, but these errors were encountered: