Closed sogaiu closed 11 months ago
In support of using //
, in Python, it appears that:
$ python
Python 2.7.18 (default, Jul 1 2022, 10:30:50)
[GCC 11.2.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> -7 // 5
-2
..and with a recent janet (see earlier comment for info about bytecode being divf
), we have:
$ janet
Janet 1.29.1-db0abfde linux/x64/gcc - '(doc)' for help
repl:1:> (div -7 5)
-2
On a terminological note, there appears to be a lack of consensus about what "integer division" refers to:
Names and symbols used for integer division include div, /, \, and %. Definitions vary regarding integer division when the dividend or the divisor is negative: rounding may be toward zero (so called T-division) or toward −∞ (F-division); rarer styles can occur – see modulo operation for the details.
via: https://en.wikipedia.org/wiki/Division_(mathematics)#Of_integers
Don't Confuse Integer Division with Floor Division
via: https://marcelkliemannel.com/articles/2021/dont-confuse-integer-division-with-floor-division/
At the time of this writing, the reference table for bytecodes lacks a row for the new bytecode instruction,
divf
, added in https://github.com/janet-lang/janet/commit/c83f3ec09757eb48bf7d48f3063b39e4d8bd9345.Perhaps inserting an appropriate row between these two rows:
is sufficient to address this issue.
I wonder what to use to indicate the operator in the rightmost column:
One candidate for
???
might bediv
because:However, this might be confusing because the row above it would presumably be this:
That is, the instruction's name in that row is
div
.May be using
//
makes sense?