mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-08 16:21:16 -03:00
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:
@@ -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
|
||||
-------------------
|
||||
|
||||
|
||||
Reference in New Issue
Block a user