# Bitwise operators and hexadecimal numbers in UR Script

**URL:** <https://forum.universal-robots.com/t/bitwise-operators-and-hexadecimal-numbers-in-ur-script/4871>\
**Category:** Product Wishlist\
**Created:** [August 7, 2019, 7:46pm UTC](https://forum.universal-robots.com/t/bitwise-operators-and-hexadecimal-numbers-in-ur-script/4871 "2019-08-07T19:46:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon95425315](https://avatars.discourse-cdn.com/v4/letter/a/e9a140/32.png) [@anon95425315](https://forum.universal-robots.com/u/anon95425315)\
**Post date:** [August 7, 2019, 7:46pm UTC](https://forum.universal-robots.com/t/bitwise-operators-and-hexadecimal-numbers-in-ur-script/4871/1 "2019-08-07T19:46:51Z")

</div>

Hello everyone, I’ve been using UR script for a while and noticed there were no bit-wise operators such as OR, AND, XOR, and shift left and right. Would there be a possibility to add these? I’ve been using custom functions that I’ve written to replace these operators:

```
def bit_and(par1, par2):
    par1bits = integer_to_binary_list(par1)
    par2bits = integer_to_binary_list(par2)
    outBits = integer_to_binary_list(0)
    i = 0
    while i < 32:
        outBits[i] = par1bits[i] and par2bits[i]
        i = i + 1
    end
    return binary_list_to_integer(outBits)
end

```

and so on for OR and XOR.

Would there also be a way to allow UR script to allow hexadecimal numbers? such as ‘0x000F’ to represent a decimal ‘16’.

These would be all QOL changes, as the absence of these can all can be worked around but I think it could speed up some scripting applications. 😉

---

<div class="post-metadata">

**Author:** ![mbush](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/mbush/32/76_2.png) [@mbush](https://forum.universal-robots.com/u/mbush)\
**Post date:** [August 8, 2019, 1:35am UTC](https://forum.universal-robots.com/t/bitwise-operators-and-hexadecimal-numbers-in-ur-script/4871/2 "2019-08-08T01:35:42Z")

</div>

@anon95425315 may want to log that also under feature requests, good idea!

Also, the to\_num() method can take hexadecimal as a valid data type and return the number so you would think that it would be possible to make the parser understand hexadecimal.
