mdb deserves a modulus operator
mdb does not at this time have a modulus operator, but it should. This is likely a hold over from adb. While there is a '%' operator, it is for integer division as the normal division operator '/' was taken due to dereferencing. As such, I've decided to co-opt '%%' to allow someone to have a modulus operator. This is currently invalid syntax.
To test this I put together a new mdb build and tested the following:
- We correctly calculated positive and negative modulus values in a way consistent with a C program or node.js.
- We correctly handled the modulus by zero case and errored
- We did not hit the division error that the division case special cases around LONG_MIN and -1.
- That we get a syntax error if missing either argument to the modulus operator or both
- Ran the mdb_v8 test suite as an additional sanity test
I also verified that on an older mdb, using the %% would always generate a syntax error, so it should not be possible to confuse it for something else.
Updated by Electric Monk 5 months ago
- Status changed from New to Closed
commit 7a2abfc9b29ea1ccc055443876ab57455e3e8f71 Author: Robert Mustacchi <firstname.lastname@example.org> Date: 2019-06-04T13:14:28.000Z 10941 mdb deserves a modulus operator Reviewed by: John Levon <email@example.com> Reviewed by: Patrick Mooney <firstname.lastname@example.org> Reviewed by: Toomas Soome <email@example.com> Reviewed by: Andy Fiddaman <firstname.lastname@example.org> Reviewed by: Gordon Ross <email@example.com> Approved by: Dan McDonald <firstname.lastname@example.org>