Two's complement: Difference between revisions

m
Line 306:
In Julia as in C, if a number n is any integer type, then -n is the two's complement of n, with type preserved. This is true even if n is unsigned.
=={{header|M2000 Interpreter}}==
 
 
<syntaxhighlight lang="m2000 interpreter">
Module Complement2{
// we use binary.and to get a number in range of byte 0 to 255
byte k, z, v
v=random(1, 255) ' there is no two's complement for zero
z=binary.and(binary.not(kv)+1, 0xFF)
k=v
z=binary.and(binary.not(k)+1, 0xFF)
print v
print z
404

edits