Shop OBEX P1 Docs P2 Docs Learn Events
Help problem bit manipulator — Parallax Forums

Help problem bit manipulator

Marc71Marc71 Posts: 14
edited 2010-12-01 06:47 in Propeller 1
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

Comments

  • kuronekokuroneko Posts: 3,623
    edited 2010-12-01 06:44
    Marc71 wrote: »
    VAR

    byte bindigit

    PUB init

    bindigit:=%00001111<-5

    The result is 11100000 - decimal 224, this is incorrect?

    the correct result is 11100001 - decimal 225!

    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.
  • Marc71Marc71 Posts: 14
    edited 2010-12-01 06:47
    Thank for help kuroneko!

    marc71
Sign In or Register to comment.