A small plug for my own script: I'm proud to present the most useful, least-work script I've ever written: `math`<p><a href="https://github.com/shawwn/scrap/blob/master/math" rel="nofollow">https://github.com/shawwn/scrap/blob/master/math</a><p><pre><code> #!/bin/sh
scale=4 # results will print to the 4th decimal
echo "scale=$scale; $@" | bc -l
</code></pre>
It just yeets all its arguments into bc -l, so you can run math 1+2-3 or math '(1024 - 7)*10' or whatever else you want. I even use it in other shell scripts, since bash's math facilities are rather limited and inconsistent across sh vs bash.<p><pre><code> :~$ echo $(((3+4)*5))
35
:~$ echo $(((3+4)*5/1024))
0
:~$ math '((3+4)*5/1024)'
.0341
</code></pre>
It has all the precision you want, as long as you only want results up to the 4th decimal.<p>It's surprising how much I use it. I find myself absentmindedly typing out math 220*1024*1024 while talking to people in meetings (what, you don't have meetings where it's crucial to know how quickly 220MB can be transferred?) and like thousands of other situations.<p>Meanwhile, funny story: I bought an iPad recently, and discovered that it's a delightful way to pass the time while shopping. You can stick it in your cart and pull up 3blue1brown and zone out while getting your pineapples. So I was doing that, and I went to reach for the calculator app to figure something out, and discovered that there is no calculator on iPads.<p>The punchline is that if you want a calculator on an iPad, it'll either cost you $5 or your soul: <a href="https://i.imgur.com/CJsDtB0.jpg" rel="nofollow">https://i.imgur.com/CJsDtB0.jpg</a><p>Someone <i>please</i> make SpeedCrunch, but MsPaint. I miss MsPaint every day. There's an OS X app called Paintbrush which is similar, but unfortunately quite buggy and somehow even more limited in certain respects. Being able to just paste a screenshot and draw a red circle within 5 seconds is something that I wish we could do in 2022. Nay, I say that it's our right as programmers to be able to do that. </rallying cry><p>EDIT: formatting. TIL you can backslash-escape asterisks on HN.