# Binary Shift: Signed or Unsigned?

- Thread: https://externals.io/message/10776
- Original archive: https://news-web.php.net/php.internals/10776
- Started by Alex Stapleton on 2004-06-25T17:24:59+00:00
- Messages: 2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #10776 — Alex Stapleton — 2004-06-25T17:24:59+00:00

URL: https://externals.io/message/10776#10776

Are << and >> signed or not? E.g.
is 1100 >> 1 = 1110 or 0110?

I am using PHP5, if I want unsigned binary shift, do i have any
options other than converting to  a string using base_convert and
writing my own function to shift the bits and then convert back to a
number?

Is what i am after planned if not availible already?

---

## #10777 — Christian Schneider — 2004-06-25T17:54:21+00:00

URL: https://externals.io/message/10776#10777 · In reply to: #10776

Alex Stapleton wrote:
> I am using PHP5, if I want unsigned binary shift, do i have any
> options other than converting to  a string using base_convert and

You could use BC: bcdiv($a, 2); to do $a >> 1;

- Chris
