You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
RBI supports bitwise negation of integers (and possibly floating-point/double values; needs confirmation), but brs currently doesn't. Let's make that work! Some details from a comment on a PR:
which looks like RBI is using a two's complement representation for numbers and does something slightly unexpected with it. not someInteger in RBI seems to take someInteger, convert to a binary representation, perform a bitwise negation on it (all 0s become 1s, all 1s become 0s), then convert back to a decimal representation in the Two's complement understanding. So for not 0 (using just 4-bits for now because I'm lazy), we have:
not 0 (decimal) == not 0b0000 == 0b1111 == -1 (decimal in two's complement)
How strange! In the not 2 * 3 example, we get:
not (2 * 3) == not 6 (decimal) == not 0b0110 == 0b1001 == -7 (decimal in two's complement)
The text was updated successfully, but these errors were encountered:
RBI supports bitwise negation of integers (and possibly floating-point/double values; needs confirmation), but brs currently doesn't. Let's make that work! Some details from a comment on a PR:
which looks like RBI is using a two's complement representation for numbers and does something slightly unexpected with it.
not someInteger
in RBI seems to takesomeInteger
, convert to a binary representation, perform a bitwise negation on it (all 0s become 1s, all 1s become 0s), then convert back to a decimal representation in the Two's complement understanding. So fornot 0
(using just 4-bits for now because I'm lazy), we have:How strange! In the
not 2 * 3
example, we get:The text was updated successfully, but these errors were encountered: