math: Add bitwise and/or functions

Just as `math "bitand(5,3)"` and `math "bitor(6,2)"`.

These cast to long long before doing their thing,
so they truncate to an integer, producing weird results with floats.

That's to be expected because float representation is *very*
different, and performing bitwise operations on floats feels quite useless.

Fixes #7281.
This commit is contained in:
Fabian Homborg
2020-08-25 16:45:31 +02:00
parent 6ec6076c16
commit 5b1c000a2e
3 changed files with 35 additions and 0 deletions

View File

@@ -75,6 +75,7 @@ Functions
- ``asin``
- ``atan``
- ``atan2``
- ``bitand``, ``bitor`` and ``bitxor`` to perform bitwise operations. These will throw away any non-integer parts and interpret the rest as an int.
- ``ceil``
- ``cos``
- ``cosh``
@@ -114,6 +115,10 @@ Examples
``math 0xFF`` outputs 255, ``math 0 x 3`` outputs 0 (because it computes 0 multiplied by 3).
``math "bitand(0xFE, 0x2e)"`` outputs 46.
``math "bitor(9,2)"`` outputs 11.
Compatibility notes
-------------------