Up to now I never needed an arithmetic shift.
I always need a binary shift.
So it would be nice to have such a function available.
It would be nice to have a binary shift
-
User_Russian
- Addict

- Posts: 1619
- Joined: Wed Nov 12, 2008 5:01 pm
- Location: Russia
Re: It would be nice to have a binary shift
There are many such requests on the forum.
viewtopic.php?t=77286
viewtopic.php?t=52929
I never needed an arithmetic shift. Logical shift was always needed, but PB doesn't support it, so I wrote the code in assembler.
viewtopic.php?t=77286
viewtopic.php?t=52929
I never needed an arithmetic shift. Logical shift was always needed, but PB doesn't support it, so I wrote the code in assembler.
-
threedslider
- Enthusiast

- Posts: 562
- Joined: Sat Feb 12, 2022 7:15 pm
Re: It would be nice to have a binary shift
We need something like that :
Only working in conditional logic ... 
Code: Select all
a = 1
n = 2
o = a Or (1 << n)
Debug o
Re: It would be nice to have a binary shift
Yes +1 but what we really need is unsigned types then the compiler can choose between logical and arithmetic shift based on the type
easy for the c backend as you only need to cast required variables to unsigned
and for asm backend I think this is all that's required to enable unsigned
viewtopic.php?t=65312
easy for the c backend as you only need to cast required variables to unsigned
and for asm backend I think this is all that's required to enable unsigned
viewtopic.php?t=65312
-
threedslider
- Enthusiast

- Posts: 562
- Joined: Sat Feb 12, 2022 7:15 pm
Re: It would be nice to have a binary shift
However it works like this :
there is separate from the | and Or 
Code: Select all
a = 1
n = 2
o = a | (1 << n)
Debug o
-
threedslider
- Enthusiast

- Posts: 562
- Joined: Sat Feb 12, 2022 7:15 pm
Re: It would be nice to have a binary shift
Nice code ! Thanks for sharingidle wrote: Mon Jan 26, 2026 10:36 pm Yes +1 but what we really need is unsigned types then the compiler can choose between logical and arithmetic shift based on the type
easy for the c backend as you only need to cast required variables to unsigned
and for asm backend I think this is all that's required to enable unsigned
viewtopic.php?t=65312
