Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
12
Task/Twos-complement/M2000-Interpreter/twos-complement.m2000
Normal file
12
Task/Twos-complement/M2000-Interpreter/twos-complement.m2000
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
Module Complement2{
|
||||
// we use binary.and to get a number in range of byte 0 to 255
|
||||
byte k, v
|
||||
v=random(1, 255) ' there is no two's complement for zero
|
||||
z=binary.and(binary.not(v)+1, 0xFF)
|
||||
print v
|
||||
print z
|
||||
print z=255-v+1 // z is type of byte always positive
|
||||
print sint(z+0xFFFFFF00)=-v // using 4bytes, we add unsinged 0xFFFFFF00
|
||||
}
|
||||
Complement2
|
||||
Complement2
|
||||
Loading…
Add table
Add a link
Reference in a new issue