Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document behavior of modulo operator #9358

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

qwertystop
Copy link

Different languages and contexts have different default behaviors for modulo where one or both operands are negative. "The remainder of an integer division" is underspecified. As such, clarification is in order.

Different languages and contexts have different default behaviors for modulo where one or both operands are negative. "The remainder of an integer division" is underspecified. As such, clarification is in order.
@dalexeev
Copy link
Member

It would be great to use a description consistent with the GDScript modulo operator. Expression supports utility functions too.

3. For negative values, the ``%`` operator and ``fmod()`` use `truncation <https://en.wikipedia.org/wiki/Truncation>`_ instead of rounding towards negative infinity.
This means that the remainder has a sign. If you need the remainder in a mathematical sense, use the :ref:`posmod() <class_@GlobalScope_method_posmod>` and

@dalexeev dalexeev added enhancement area:manual Issues and PRs related to the Manual/Tutorials section of the documentation cherrypick:4.1 cherrypick:4.2 labels May 11, 2024
@dalexeev dalexeev added this to the 4.3 milestone May 11, 2024
Co-authored-by: Aaron Franke <arnfranke@yahoo.com>
@qwertystop
Copy link
Author

That this page uses "modulo" and the other (linked by @dalexeev ) uses "remainder" led to me only finding this and not the other when I searched – terminology around this is often a bit fuzzy. Even if one is more technically accurate than the other, it might be useful to have both in docs to make sure it is relatively searchable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:manual Issues and PRs related to the Manual/Tutorials section of the documentation cherrypick:4.1 cherrypick:4.2 enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants