Page 1 of 1

Posted: Sun Apr 13, 2003 3:10 am
by BackupUser
Restored from previous forum. Originally posted by CodeMeister.

Are there any binary bit-shifting functions in PB such as shift left or shift right? I didn't see any mention in the docs. Thx.

"If stupidity got us into this mess, why can't it get us out?"

Posted: Sun Apr 13, 2003 4:01 am
by BackupUser
Restored from previous forum. Originally posted by wayne1.

Look under General Topics
variables types and operators
in the reference manual :)

Posted: Sun Apr 13, 2003 4:09 am
by BackupUser
Restored from previous forum. Originally posted by CodeMeister.

Thx wayne1... right where you said it would be.... 8^)

"If stupidity got us into this mess, why can't it get us out?"

Posted: Sun Apr 13, 2003 11:38 am
by BackupUser
Restored from previous forum. Originally posted by BalrogSoft.
Originally posted by CodeMeister

Are there any binary bit-shifting functions in PB such as shift left or shift right? I didn't see any mention in the docs. Thx.

"If stupidity got us into this mess, why can't it get us out?"
There isnt any function to do this, but in my chip 8 emulator, exist two emulated instructions that are right shift and left shift, and in a document i discover how to make it very fast:

Right shift:
Bit2.s=Bin(Val(Right(Value.s,1)))
Bitshifted=Val(Right(Bit2.s,1)) ; save the bit losed
Val(Value.s)/2 ; and this the real bit shift to right, only divide the value by 2

Left shift:
Bit1.s=Bin(Val(Left(Value.s,1)))
Bitshifted=Val(Left(Bit1.s,1)) ; save the bit losed
Val(Value.s)*2 ; and make the left shift


if you only need the shift data and not the losed data, only multiply or divide the value by 2 to make the shift operation.

bye, Balrog Soft

Balrog Soft
Amiga and PC Coder
http://www.balrogsoftware.com
[url]mailto:balrog@balrogsoftware.com[/url]

Posted: Sun Apr 13, 2003 12:11 pm
by BackupUser
Restored from previous forum. Originally posted by fred.

Have you tried: > ?

Fred - AlphaSND

Posted: Sun Apr 13, 2003 6:45 pm
by BackupUser
Restored from previous forum. Originally posted by Skipsy.

Hi,

Perhaps I didn't understood your need but for a 1 bit left shift you
can multiply by 2 and for a right shift divide by 2

Then of course you can format the binary data to 4, 8 or more bits,
with a AND (&).


"If you want to touch the sky,
f**k a duck and try to fly"

Posted: Sun Apr 13, 2003 9:37 pm
by BackupUser
Restored from previous forum. Originally posted by CodeMeister.

Thx guys... I found the > operators, just what I needed.


"In God we trust, all others we virus scan." ~Author Unknown