Two's complement: Difference between revisions

Content added Content deleted
m (J)
(→‎{{header|J}}: second draft)
Line 53: Line 53:


=={{header|J}}==
=={{header|J}}==
J uses twos complement natively:
<lang J> -3
<lang J> -3
_3</lang>
_3</lang>

We can see this by extracting bits representing the number. In this example, we limit ourselves to 8 bits:

<lang J> (8#2)#:3
0 0 0 0 0 0 1 1
(8#2)#:-3
1 1 1 1 1 1 0 1</lang>

=={{header|Z80 Assembly}}==
=={{header|Z80 Assembly}}==
===8-Bit===
===8-Bit===