Is there a command line calculator that will let me do bit operations and has good support for hex. E.g. for operations like:

0xff << 3
(1 << 5) ^ 0x77

Bad solutions:

  • bc - laughable support for hex
  • Frink - might work, but it's a big java app and not easily installable through Brew etc.
  • radix-calc - close to what I want, but I'd prefer a REPL, with support for variables etc.
  • Python - too verbose for printing hex etc.

The software should work on a Mac and ideally be open source. Must support standard C operators, and ideally setting variables and printing them as hex.

  • Isn't OS X just a GUI over BSD? I'm not trying to start a flame war here with that "just". But, maybe a UNIX or even Linux tag might attract more answers, since it's a command line utility you are after.
    – Mawg
    Commented Dec 5, 2018 at 13:20

1 Answer 1


PowerShell (PowerShell Core) comes close to what you want. It's a REPL, supports hex, supports variables, supports defining functions. (It's more than a plain calculator, though!)


It supports the functionality of bitwise operators, but not with the C symbols - e.g., << is -shl, | is -bor, and so on - see Get-Help about_Arithmetic_Operators for details.

Hex output is awkward and verbose; you'd pretty much have to do it as "{0:X4}"-f (insert calculation here) (4 is the number of hex digits to use; you can use more or less as you choose) - but hex input is standard - 0x followed by hex digits.

  • Not a terrible option. I feel like radix-calc is better. Maybe I'll just modify it to have a REPL.
    – Timmmm
    Commented Aug 6, 2018 at 15:06
  • @Timmmm - You consider this not a terrible option? How is this better than Python? Python uses C symbols and standard hex input; and hex output is achieved by simply using the hex function. Obviously Python has a REPL, variables, and functions. It's even already installed on your Mac.
    – John Y
    Commented Oct 5, 2018 at 22:25
  • Yeah after trying it Python does seem a better option.
    – Timmmm
    Commented Oct 6, 2018 at 12:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.