ab

"Programmer's"/Hex/Binary Calculator by Splunge.foo Build 1

A command line style calculator. Use ? as a command to restore this panel.

There is no operator precedence. Operations run left to right.

The default input mode (decimal,hex,octal,binary) as shown in the prompt is how literal values are treated. Enter d/x/o/b as a command to switch modes.

Literal values can be prefixed with d/x/o/b or 0d/0x/0o/0b to change the radix for that value only.

The previous result is implicit on the command line (like a calculator). So just entering +5 will add 5 to the last result just like a calculator. Only special thing, that does not work for negative literals at the start of the string as we can't tell if you mean to subtract from the current value, or enter a new negative literal. So if a negative value is at the start of the string you need to p - <value> to subtract from the last value.

Previous values sit in stack and can be accessed with p<n> with n defaulting to 0 if omitted. The same for accessing memories, m<n>.

Memories: m<n>s = set value. m<n>c = clear value. m<n><op> to apply operation.

Memories can be named with every command except clear m<n><op>"your description"

OperatorNotes
+ - * / %Standard arithmetic. Divide will also show the modulo.
& | ^Bitwise AND, OR, XOR.
<< >>Arithmetic shift left/right. Right shift preserves top bit. Right hand value is number of bits, except when used on memory i.e. 5 m1>> to shift memory 1 right by 5 bits. This is currently working on the whole value, TODO is a method to limit calculations to a specified number of bits.
>>>Logical shift right. Top bit is set to 0. Not currently implemented.
! ~Bitwise NOT & NEGATE. These do not need a right hand side number. Not currently supported on memories.

Unfortunately to copy at the moment you need to select then right-click copy.

In the results output, if the value overflows the number of indicated bits (i.e. u16), then the label will be red.

Todo

For help or suggestions please sign up to Splunge.foo Discord Server