Two's complement: Difference between revisions
→{{header|Ruby}}: Add Ruby
m (Removed unwanted comments.) |
(→{{header|Ruby}}: Add Ruby) |
||
Line 492:
1: #11111101b
</pre>
=={{header|Ruby}}==
Ruby integers have has a built-in 'one-complement'method: '''~''', which flips all bits. Adding 1 leads to a negative integer:
<syntaxhighlight lang="ruby">~42 + 1 # => -42
</syntaxhighlight>
=={{header|Wren}}==
Strictly speaking, Wren doesn't have integers. Instead all numbers are 'IEEE 754' 64 bit floating point values (their underlying C type being ''double'') and negative numbers are therefore represented using the ''offset binary'' method rather than ''two's complement''.
|