TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

TUI calculator for programmers working close to the bits

127 pointsby romesover 2 years ago

18 comments

gavinhowardover 2 years ago
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&#x27;s complement signed integers.<p>See the manual ([2]), especially the extended math library section ([3]).<p>It&#x27;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:&#x2F;&#x2F;git.yzena.com&#x2F;gavin&#x2F;bc" rel="nofollow">https:&#x2F;&#x2F;git.yzena.com&#x2F;gavin&#x2F;bc</a><p>[2]: <a href="https:&#x2F;&#x2F;git.yzena.com&#x2F;gavin&#x2F;bc&#x2F;src&#x2F;branch&#x2F;master&#x2F;manuals&#x2F;bc&#x2F;A.1.md" rel="nofollow">https:&#x2F;&#x2F;git.yzena.com&#x2F;gavin&#x2F;bc&#x2F;src&#x2F;branch&#x2F;master&#x2F;manuals&#x2F;bc&#x2F;...</a><p>[3]: <a href="https:&#x2F;&#x2F;git.yzena.com&#x2F;gavin&#x2F;bc&#x2F;src&#x2F;branch&#x2F;master&#x2F;manuals&#x2F;bc&#x2F;A.1.md#extended-library" rel="nofollow">https:&#x2F;&#x2F;git.yzena.com&#x2F;gavin&#x2F;bc&#x2F;src&#x2F;branch&#x2F;master&#x2F;manuals&#x2F;bc&#x2F;...</a>
ghewgillover 2 years ago
For old school fans, the HP-16C [1] calculator provided these kinds of functions in a handheld calculator, in 1982. This was the only &quot;programmer&quot; 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:&#x2F;&#x2F;hpmuseum.org&#x2F;hp16.htm" rel="nofollow">https:&#x2F;&#x2F;hpmuseum.org&#x2F;hp16.htm</a> [2]: <a href="http:&#x2F;&#x2F;hp16c.org" rel="nofollow">http:&#x2F;&#x2F;hp16c.org</a> [3]: <a href="https:&#x2F;&#x2F;hp15c.com" rel="nofollow">https:&#x2F;&#x2F;hp15c.com</a>
评论 #34592766 未加载
评论 #34589928 未加载
donaldihunterover 2 years ago
There’s also Bitwise [0] which has support for IP addresses<p>[0] <a href="https:&#x2F;&#x2F;github.com&#x2F;mellowcandle&#x2F;bitwise">https:&#x2F;&#x2F;github.com&#x2F;mellowcandle&#x2F;bitwise</a>
评论 #34590384 未加载
评论 #34587613 未加载
ilytover 2 years ago
I use qalc&#x2F;qalculate, it has gui&#x2F;cli version. I got pissed dealing with bc usability problems (&quot;yes I pressed ctrl+c, you know I want to quit, why you ask me to type some command for it?&quot;).<p><pre><code> &gt; 10+0xff+0b00010 -&gt;hex 10 + 255 + 2 = 0x10B </code></pre> Also does some fancy unit conversion stuff like &quot;how long it would take to transfer X gigabytes over Y Mbit link<p><pre><code> &gt; 200GB &#x2F; (100Mbit&#x2F;s) (200 gigabytes) &#x2F; ((100 megabits) &#x2F; second) = 4 h + 26 min + 40 s</code></pre>
评论 #34591314 未加载
评论 #34593919 未加载
nonrandomstringover 2 years ago
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 &quot;views&quot; (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&#x2F;sockets&#x2F;fifos.
ladbergover 2 years ago
Pretty nice looking! Also for anyone on a Mac I find programmer mode (⌘-3) in the built-in Calculator.app pretty useful for this purpose.
评论 #34586473 未加载
评论 #34587888 未加载
6thover 2 years ago
My goto is speedcrunch <a href="https:&#x2F;&#x2F;heldercorreia.bitbucket.io&#x2F;speedcrunch&#x2F;" rel="nofollow">https:&#x2F;&#x2F;heldercorreia.bitbucket.io&#x2F;speedcrunch&#x2F;</a>
artisanspamover 2 years ago
Looks great! But you may want to consider a different name as PCalc is already a popular calculator app:<p><a href="https:&#x2F;&#x2F;pcalc.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;pcalc.com&#x2F;</a>
评论 #34587903 未加载
zabzonkover 2 years ago
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&#x2F;hex&#x2F;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
mbork_plover 2 years ago
That&#x27;s very neat. I wouldn&#x27;t use it even if I had such a need - Emacs Calc seems to do everything this does and much more - but I&#x27;m glad people create such nice tools.
AceJohnny2over 2 years ago
Offtopic, but I remember implementing a calculator was Compilers &amp; 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&#x27;s handled by the <i>lexer</i>, which is step that handles processing input into &quot;lexical&quot; elements, which are then passed to actual &quot;parser&quot; that constructs the syntactic structure)
xvilkaover 2 years ago
Interesting tool! In Rizin[1][2] we have a &quot;visual bits&quot; mode, see &quot;Vb1&quot; command. Moreover, there&#x27;s &quot;rz-ax&quot; command, supporting various number systems and bits, see &quot;rz-ax -h&quot; help.<p>[1] <a href="https:&#x2F;&#x2F;rizin.re" rel="nofollow">https:&#x2F;&#x2F;rizin.re</a><p>[2] <a href="https:&#x2F;&#x2F;github.com&#x2F;rizinorg&#x2F;rizin">https:&#x2F;&#x2F;github.com&#x2F;rizinorg&#x2F;rizin</a>
mjcohenover 2 years ago
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.
评论 #34588997 未加载
jwrover 2 years ago
[pulls out HP-16C from drawer under the desk]<p>…I think I&#x27;ll stay old school and continue pressing those satisfying physical keys.
makeworldover 2 years ago
Anyone know the font in the screenshot?
评论 #34587562 未加载
mncharityover 2 years ago
Any suggestions for similar &quot;close to the bits&quot; but with support for floats?
评论 #34589239 未加载
snvzzover 2 years ago
I rotate between my TI-86, TI-89 and v200.
评论 #34591641 未加载
thanatos519over 2 years ago
Nice, but I would prefer an RPN version.