Help problem bit manipulator
Marc71
Posts: 14
hello!
I have a problem with this code:
VAR
byte bindigit
PUB init
vga.start(16)
bindigit:=%00001111<-5
vga.bin(bindigit,8)
vga.out($0D)
vga.dec(bindigit)
The result is 11100000 - decimal 224, this is incorrect?
the correct result is 11100001 - decimal 225!
where is error?
Thanks for help!
marc71
I have a problem with this code:
VAR
byte bindigit
PUB init
vga.start(16)
bindigit:=%00001111<-5
vga.bin(bindigit,8)
vga.out($0D)
vga.dec(bindigit)
The result is 11100000 - decimal 224, this is incorrect?
the correct result is 11100001 - decimal 225!
where is error?
Thanks for help!
marc71
Comments
Rotate & Co work internally on 32bit quantities, not bytes. Meaning the 1 you expect in bit 0 is actually now in bit 8 (which is not visible for a byte). So if you really need byte rotation then you have to do it manually.
marc71