Shameless plug: my `bc` [1] can also display bits like this, as well as do bit operations.<p>It automatically detects how many bits your number must have and uses the minimum, or you can tell it the standard bit sizes or even use a custom bit size. It will handle 2's complement signed integers.<p>See the manual ([2]), especially the extended math library section ([3]).<p>It's also a normal `bc`, with every feature of all other implementations.<p>I should add floating point support, though.<p>[1]: <a href="https://git.yzena.com/gavin/bc" rel="nofollow">https://git.yzena.com/gavin/bc</a><p>[2]: <a href="https://git.yzena.com/gavin/bc/src/branch/master/manuals/bc/A.1.md" rel="nofollow">https://git.yzena.com/gavin/bc/src/branch/master/manuals/bc/...</a><p>[3]: <a href="https://git.yzena.com/gavin/bc/src/branch/master/manuals/bc/A.1.md#extended-library" rel="nofollow">https://git.yzena.com/gavin/bc/src/branch/master/manuals/bc/...</a>
For old school fans, the HP-16C [1] calculator provided these kinds of functions in a handheld calculator, in 1982. This was the only "programmer" calculator that HP has ever made.<p>There is a simulator (for Windows) available [2]. (No affiliation; but I made a simulator for the cousin calculator HP-15C [3]).<p>[1]: <a href="https://hpmuseum.org/hp16.htm" rel="nofollow">https://hpmuseum.org/hp16.htm</a>
[2]: <a href="http://hp16c.org" rel="nofollow">http://hp16c.org</a>
[3]: <a href="https://hp15c.com" rel="nofollow">https://hp15c.com</a>
There’s also Bitwise [0] which has support for IP addresses<p>[0] <a href="https://github.com/mellowcandle/bitwise">https://github.com/mellowcandle/bitwise</a>
I use qalc/qalculate, it has gui/cli version. I got pissed dealing with bc usability problems ("yes I pressed ctrl+c, you know I want to quit, why you ask me to type some command for it?").<p><pre><code> > 10+0xff+0b00010 ->hex
10 + 255 + 2 = 0x10B
</code></pre>
Also does some fancy unit conversion stuff like "how long it would take to transfer X gigabytes over Y Mbit link<p><pre><code> > 200GB / (100Mbit/s)
(200 gigabytes) / ((100 megabits) / second) = 4 h + 26 min + 40 s</code></pre>
I like the idea and hope you grow it into something of a pen-knife for
numbers. Being able to change the bit width and base on the fly looks
neat. I tend to pull up a Python shell for lots of tasks. Often what I
want is a dumper (like od, hexdump or tcpdump) with the ability to
filter steams with masks and whatnot, like wireshark, and display the
results in various "views" (hex, binary etc as you have provided). It
is hard to make any one tool do all that - but also hard to find
nicely pipeable little tools to work in a Unix way. It might be good
to consider the contexts people will use your tool wrt
stdio/sockets/fifos.
My goto is speedcrunch <a href="https://heldercorreia.bitbucket.io/speedcrunch/" rel="nofollow">https://heldercorreia.bitbucket.io/speedcrunch/</a>
Looks great! But you may want to consider a different name as PCalc is already a popular calculator app:<p><a href="https://pcalc.com/" rel="nofollow">https://pcalc.com/</a>
i had a casio (i think) calculator with a fold-out keyboard with all the hex digits (A-F) and the boolean operators. it would take input in binary, and hex, but not octal. my then gf bought it me as a bday present. appreciated, but not much used as at the time i could do all the binary/hex/decimal conversions in my head, not to mention converting them into z80 opcodes.<p>sadly, no more - too old and forgetful<p>this would have been about 1984
That's very neat. I wouldn't use it even if I had such a need - Emacs Calc seems to do everything this does and much more - but I'm glad people create such nice tools.
Offtopic, but I remember implementing a calculator was Compilers & Parsing 101.<p>I mention this because the Readme specifically calls out the various ways of inputting an expression, which is a non-issue with any compiler background. (It's handled by the <i>lexer</i>, which is step that handles processing input into "lexical" elements, which are then passed to actual "parser" that constructs the syntactic structure)
Interesting tool! In Rizin[1][2] we have a "visual bits" mode, see "Vb1" command. Moreover, there's "rz-ax" command, supporting various number systems and bits, see "rz-ax -h" help.<p>[1] <a href="https://rizin.re" rel="nofollow">https://rizin.re</a><p>[2] <a href="https://github.com/rizinorg/rizin">https://github.com/rizinorg/rizin</a>
Many calculators will do this. I like the CalcTastic Pro for android. This has a programmer mode, which will do all these and more. Its scientific mode will operate with complex numbers as well as real numbers. It can even take the complex factorial.<p>It can operate on rpn as well as algebraic.<p>It is good.