Two's complement: Difference between revisions
Content added Content deleted
m (Removed unwanted comments.) |
(→{{header|Ruby}}: Add Ruby) |
||
Line 492: | Line 492: | ||
1: #11111101b |
1: #11111101b |
||
</pre> |
</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}}== |
=={{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''. |
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''. |