Fun fact about SpeedCrunch history, the software descends from an off-hand blog post by Roberto Alsina, a KDE developer, complaining about KCalc usability [1]. Back then developers were often just unthinkingly cloning 'skeuomorphic' interfaces like Apple used back then, designing user interfaces that resembled physical objects instead of taking advantage of the opportunities afforded by computers.
His blog post elicited several rapid responses from developers taking his PyQt-based mockup and turning it into a 'real' application ([2], [3]). One of those was Ariya Hidayat's "SpeedCrunch", which has been actively maintained up to the present day. I can't find Ariya's original 2004 announcement, I think the original link was http://ariya.pandu.org/blog/archives/2004/10/calculator-feve... but that's dead now.
But it's really neat to see how this all started from a day or two of hacking on a solution to a simple problem.
I used to use this back when I mained Windows. Ever since moving primarily to Linux, and getting familiar with Emacs, Calc mode simply beats every calculator I've ever used in total functionality. However, there are certain cases where I also like to use https://insect.sh if lots of units are involved.
Emacs Calc (not unlike much of the rest of Emacs) is a little ... special. By default, it calculates 4/2*2 as 1, because multiplication has a higher precedence than division.
I think some people learned P-E-MD-AS as if MD and AS didn't have the same precedence. I mean, it's a convention anyway, so they aren't really "wrong" insomuch as just being unusual. But it does seem like an odd thing to disagree about.
I think there's also some confusion about whether the / symbol is actually being used as a single line equivalent to a fraction, which might introduce some ambiguity? I forget. The number of ways that people can misunderstand things is infinite, so it can be hard to keep track.
Anyway, parentheses are cheap and misunderstandings, even when the other party ought to take the blame, can be expensive, so I've taken up the habit of being generous with the things.
This may be slightly off topic, but what are some other small, lesser known websites like this one that people use regularly? For me, it'd be https://rubular.com and https://crontab.guru. I've used those 2 sites pretty regularly across my entire career.
I've been using and loving qalculate for years as part of Debian but strangely it isn't in the current Debian stable package list (bullseye). So I just switched to SpeedCrunch and it seems like a good replacement for most quick calculations where you still want to see some history.
I'm using Emacs in a floating window under I3wm that I can toggle into the scrap buffer and back with a key binding. Doing the same with one terminal. This inspiration for this also came from the console in Quake.
I LOVE SpeedCrunch. I do not need a calculator very often, but when I do, this is my calculator of choice. It doesn't support graphing, but it understands units, which is both useful and cool.
I like the UI, too, for being simple but very much functional without getting in my way. And it supports a persistent history across sessions, which I also like.
Using and liking it also.
It is just that I need it so rarely that I fall back into the RPN that I'm used to from Emacs calc. Speedcrunch does not have a RPN mode, does it? That would be splendid.
SpeedCrunch looks very promising, and I've used it a lot in the past. I'm sad to see that they still haven't released the order of operations bug fix [0] they made in 2017.
SpeedCrunch does some operations in an order most people wouldn't expect. For example, SpeedCrunch says 1/2(-9.8) = -0.05102040816326530612
You could make 1/2x where x = 4 evaluate to either 2 or 0.125, but either choice will have surprising results in some cases or to some people. Perhaps a better choice, especially for an interactive calculator, is to adopt partially ordered operator precedence, and reject the expression as ambiguous. Then the user can insert parentheses to disambiguate.
In a CFG this is easy enough to express. Here's an untested and at any rate incomplete CFG demonstrating the technique:
expr ::= term | term "+" expr | term "-" expr
term ::= quotient | product
quotient ::= atom "/" atom | atom "/" quotient
product ::= atom product | atom "*" product | atom
atom ::= number | variable | "-" atom | "(" expr ")"
But typical parser generators don't give you an easy way to provide a useful error message there.
That version of the grammar, btw, avoids left recursion, so it ought to work as a PEG, but at the cost of the wrong associativity for "/" and "-". You either need to use left recursion or restructure the syntax tree afterwards.
> You could make 1/2x where x = 4 evaluate to either 2 or 0.125
Ouch, you just made me think that if I see this equation just "horizontally" like it's presented here, I would say 2. But if I imagine it like you would write it on paper, I would answer 0.125.
That is a thing you can do, and for example units(1) does just that, but doing it creates the usability problems we are discussing in its thread. My comment is aimed at solving those problems, not worsening them.
The disconnect is that a lot of people mentally treat implicit multiplication with a higher priority than explicit, which is pretty understandable. For instance:
1/3x
is likely to be understood as 1/(3*x), because otherwise it would’ve been written like x/3. If that’s true, then so surely
1/3(x)
should be the same, right?
Smarter people than I have argued both sides of this, and I don’t have a strong opinion except to use parentheses if there’s any possible ambiguity. Just saying, I totally understand why you’d come to that conclusion, and I probably would too.
The part that confuses me is why someone would think the SpeedCrunch implementation is correct:
Say again that you have 1/3x. This is implicitly stating 1/3x. However, no parenthesis are used, and multiplication & division are on the same level in the order of operations, so the expression gets evaluated sequentially from left to right.
If you have 1/3(9.8), evaluating the parenthesis gives you 9.8. So you now have 1/39.8. The expression inside the parenthesis gets evaluated first, then the final result is just multiplied by whatever precedes or succeeds the parenthetical if no other term is given. So 1/3+(9.8) would obviously evaluate to be 1/3+9.8.
Again, if the parenthesis aren't enclosing operations within themselves, then they shouldn't modify the way you'd evaluate the expression. I've had this problem with SpeedCrunch many times over and wish they would update it. Still the best desktop calculator IMO.
Implied multiplication (with no operator) has a higher precedence than explicit multiplication (with an operator). Most mathematicians see it this way.
Really though, order of operations is just a convention. Practically, I'd think of PEMDAS as descriptive rather than proscriptive (nobody is going to revoke your math license if you and your friends violate PEMDAS together). Frequent topics of debate or confusion seem to indicate a edge case in the living convention. Therefore, I think you are smarter than either of the debaters if you stick with the parentheses.
I would be confused if 1/2gt^2 would mean anything but 1/2 g t^2 and 0.5 g t^2. 1/3x in isolation may look a bit unusual, but with context the choice between 1/3 x and x / 3 may actually convey additional information, information about the structure of the calculation. Manipulating an equation into some kind of normal form may lose information.
Yes, that answer is incorrect since it breaks with calculator conventions. The contents of the parentheses are calculated first (P in PEMDAS), and then the multiplication is done later (MD in PEMDAS). Implicit multiplication (which does not explicitly use a multiplication sign) has the same priority as any other multiplication:
a/b(c) = a/b*c = (a/b)*c
Since SpeedCrunch only accepts input in a single line, this would be the least unexpected way to interpret the expression, and consistent with how graphing calculators operate.
A horizontal fraction bar, which SpeedCrunch does not support (since it only accepts single-line input), implies parentheses around the numerator and denominator. For example:
ax
-- = (ax)/(by) = (a*x)/(b*y)
by
compared to
ax/by = a*x/b*y = ((a*x)/b)*y
(If the above is not displayed correctly, please view this comment on the HN website.)
Implicit multiplication is a point of frequent confusion:
To guarantee that the expression does not get misinterpreted, the person writing the expression should always add parentheses/brackets and explicit multiplication signs, or use horizontal division bars where possible, to make the expression unambiguous.
Not even calculators agree on this. Here's a picture of my Casio fx-83ES and fx-83GT calculators giving different answers to "8/2(2+2)": https://i.imgur.com/SsKUQrE.jpg
Both answers are completely, 100% correct according to the operator precedence table in their manuals. I also have a Casio fx-83MS and fx-991ES, both give 1 as the answer.
Others I have are a Casio fx-570CD and a Casio statistical calculator I don't remember the model of, neither of which support implicit multiplication, and a SwissMicros DM42, which is RPN and doesn't have to deal with operator precedence.
Looking at this issue and then trying Qalculate! as some of the other commenters to this post have mentioned.... I tried 1/2(-9.8) and it calculated it as -0.05102040816 as I was doing the entry. As soon as I hit enter, however, it popped open a dialog box saying "The expression is ambiguous" and asked me to select an interpretation of expressions with implicit multiplication, setting a preference for later use. The choices were:
That's the perfect way to deal with this case. I've been using Qalculate! for quite some time, but never saw this dialog because I've apparently never entered an ambiguous expression before. Thanks for sharing this.
I have to say, it's really disappointing to see similar models from the same brand act differently. Thanks for testing this out and shedding more light on this issue.
You're right. The division sign is also unambigious. Unfortunately, it's not usually found on keyboards so many people are accustomed to using slashes.
SpeedCrunch and other calculator apps still need to have an unambiguous way of interpreting the expression when the user types or pastes in a slash. The apps could convert slashes to division signs before displaying them on the screen, since that's how the symbols should be interpreted. This is how GNOME Calculator resolves the ambiguity.
It’s a question of whether the above is supposed to mean (1/2)(-9.8), or 1/(2(-9.8)). Technically it’s ambiguous (I think), in practice it’s obviously the former, because if it was the latter you’d write it as 1/(2-9.8).
It also has a persistent history, variables, functions, base conversion, etc. I guess it doesn't have unit conversion or a math library, but it's a great programmers calculator.
Hah, I used gdb print expression for a calculator for decades (especially p/x for hex conversions.) I finally switched to "just fire up a python repl instead" around 2010...
I love the JS console for this sort of thing. It has autocomplete for math functions, lists and variables. And I know (and have muscle memory for) the JS math library already.
The best part is its available anywhere, on any computer, in any web browser without installing anything.
Seeing as others in this thread use the bog standard console - and I’ve seen other developers do exactly what you’re referencing - it seems such console usage isn’t unique to you at the very least.
Their demo of their efficient interface compared to GNU Calc:
SC: 5+8 Enter [4 keys, 1 shift]
Calc: 5 RET 8 + [4 keys, 1 shift]
SC: 5*(113+23) Enter [11 keys, 3 shifts]
Calc: 5 RET 113 RET 23 + * [10 keys, 1 shift]
SC: 7*ans Enter [6 keys, 1 shift]
Calc: 7 * [2 keys, 1 shift]
SC: sqrt(1231+41) Enter [14 keys, 3 shift]
Calc: 1231 RET 41 + Q [9 keys, 1 shift]
Maybe it’s more efficient than clicking buttons with a mouse but it doesn’t feel more efficient than the calculator I already use, nor does it seem to be better integrated with the software I use. It doesn’t even seem more efficient than the scientific calculator I used in high school.
I think I’m put off more by the lack of graphing and (as far as I could tell skimming their site) array/vector/matrix functions, which are the main things I do with Calc.
You're comparing infix with RPN. There are more factors there than just number of keystrokes; not everyone enjoys working with RPN or finds it comfortable. RPN is a deliberate tradeoff in favor of speed/efficiency at the expense of other things.
The calculator I used in school was infix but, unlike this calculator, had:
- single buttons for common operations like +, * or sqrt
- no shifted parentheses
- display-style input of fractions and exponential so you got some visual clue if your brackets weren’t totally wrong
- single (sometimes shifted) buttons for functions like cos/tan/arcsin/…
- specialised shift operators which mostly meant inverse or hyperbolic
GNU Calc has most of these (+ and * are still shifted but all common operations are shifted. Parentheses are not used because of RPN. Display-style (‘big’) presentation is optional but ugly ascii art. Press H for hyperbolic, I for inverse).
I think gnu Calc is lacking a bit in entry of algebraic expressions but I don’t think speed crunch is better. I’d like to see something that let you place a ‘(‘ somewhere ‘backwards’, or in other words a feature for ‘I would like to parenthetical use some of the past expressions. Please let me interactively choose them without fiddling with cursor movement commands.’
I don’t have a horse in the race (I find myself still using the default of whatever OS I’m using more often than I specifically choose SC) but I will say that one can easily configure SC to operate with past calculated results and other references from previous operations, just as you did with your cited GNUCalc examples. If such shortcuts are utilised, one will find SC requires the same number keystrokes - or fewer.
#!/bin/sh
scale=4 # results will print to the 4th decimal
echo "scale=$scale; $@" | bc -l
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.
It has all the precision you want, as long as you only want results up to the 4th decimal.
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.
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.
The punchline is that if you want a calculator on an iPad, it'll either cost you $5 or your soul: https://i.imgur.com/CJsDtB0.jpg
Someone please 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>
EDIT: formatting. TIL you can backslash-escape asterisks on HN.
> ... and discovered that there is no calculator on iPads.
Wait, what!? I have never used an iPad but this just floors me.
Imagine going to an Apple store, asking about the new iPad, listening to the pitch, nodding along as they play fruit ninja and draw a smiley face with a stylus and then asking "what's the 12th digit of the square root of two?".
How can it not have a calculator? I mean, what?
I'm old and jaded and consumer grade technology hasn't amazed me or made my life better in well over a decade but this is a whole new level.
I’m like you. On Linux there’s KolourPaint that does the job, but on macOS I never found any desktop app that does what I want. In the browser, there’s this clone [1] that mimicks all the features of the original one. You can "open" a file, "save" it, and everything in the meantime is saved in local storage.
Ever since Windows released their embarrassing touch-friendly calculator app which takes 1+ seconds to start, SpeedCrunch has been my goto across platforms.
I was recently doing some (silly) combinatorical math, where I wanted to know factorial(400_000) and SpeedCrunch happily produced the answer immediately. Incredibly satisfied.
I've been using this as my Linux GUI calculator for a while (maybe a decade?). It's a good blend of functionality and simplicity and after I started using it I literally haven't looked for anything else.
A little bit jank, but there is also a port for android available[0]. It still has SI prefixes and unit conversion, but you need to have a good keyboard to really take advantage of it.
[0] https://github.com/mikkosyrja/speedcrunch-android
I didn't know there was an Android port. Thanks for the link!
On Android, so far, I prefer Calculator++ - it supports complex numbers (not that I need those, but sqrt(-1) returns i) and has fairly capable graphing.
I loved this on Windows but haven't used it since switching to macOS since it seems to not support Retina screens very well, anyone know of a workaround?
I have a single, but major, complaint with Soulver: version 3 for iOS/iPadOS doesn’t exist yet. There are a lot of calculations I’d want to do both at my desk and out on the road, and I’d like them synced. Calca handles that pretty well and I’ve been using it over Soulver lately for that one specific reason. I like Soulver more than Calca, though, and the second Soulver 3 for iOS comes along I’ll switch back.
Looking at its inner working seems it's uses SQLite as storing. While a few hundred entries in any SQLite DB should be a breeze to parse and show under a second, maybe the person(s) involved in this project are not that DB proficient and made some rookie mistakes. Maybe they'll notice this and improve it's history speed as well, shouldn't be a problem for any SQL developer with a bit of experience in hands.
Looks like my delay happens when converting between units. It's almost like it prompts me to confirm when I press Enter so I end up having to hit it twice. Other than this it is really great.
I often have to do many simple calculations (adding numbers from a pdf,...) and having full history and being able to keep speedcrunch over the other windows is perfect.
I also increased font-size dramatically to improve readability on big screens.
Sure, there are more advanced tools. But the simplicity and lightness on ressources is what makes it my go-to calculator.
After trying a lot of different calculators, I just settled on this little shell script to launch/raise a nodejs repl with FN+Backpspace:
if [ $(xdotool search --name "calc repl") ]; then
xdotool search --name "calc repl" windowraise
else
xfce4-terminal \
--title="calc repl" \
--color-bg=#123 \
--color-text=#fec \
--hide-scrollbar \
--font="Deja Vu Sans Mono 14px" \
--geometry 40x14 \
--execute node -i -e "$JSREPL"
fi
($JSREPL just contains some extra functions that I want in a calculator)
I can easily go back to previous calculations and results, define vars, run loops whatevs. Having it on a key combo and launching the terminal with a distinct text/bg color really makes a difference. It also launches faster than most other calculators I tried. For my purposes (non-scientific, mostly programming stuff), it's been great.
Whoa, I didn't realize it had color themes and font options on top of everything else. I just subbed it in for my normal calculator software shortcut, this is great. Thanks for posting op.
(Edit: The HTML export feature even preserves the color theme. It's a web publishing tool now! Hahaha)
Love it. Use it as my default calculator when I need one occasionally. I would love to see support for plotting graphs and solving equations. Also a more touch friendly UI would be nice when using my 2-in1 laptop in tablet mode when doing math excercises for uni.
I wanted to like this, but when I tried it on Windows, setting the font size and/or color theme made the input bar/expression editor disappear. Absolutely nothing would bring it back, not changing the settings back or even uninstalling and reinstalling. I assume it works better in a linux.
(I'd report a bug, but a calculator program making itself unusable in less than a minute with steps I can't precisely recreate kinda kills my enthusiasm for that process.)
It would be nice to know how numeric types are implemented, especially for something advertised as high-precision. Does it use some arbitrary precision floats or what?
From the documentation:
* However, only about 78 significant digits are stored at any point.
* SpeedCrunch stores integers with a precision of up to 256 bits.
This looks great but I wish it had some of the features that NaSC [0] has. It's a really amazing tool but it's awfully crashy to the point where it's barely usable. That being said being able to say `solve(... = 512 MiB)` and getting an answer is unbelievably amazing.
Somehow, it seems speedcrunch has a problem in dealing with big numbers. For example, I can do:
(3(7^204+7^202+7^200)+7(3^204+3^200)-210) mod 10
in the calculator that comes with linux and get the right result (which is 7), but speedcrunch overflows and outputs 0. I've set the result format to fixed decimal and precision to 50 digits, but that doesn't seem to make a difference.
Edit: Just tried it with insect, which also gets it wrong.
If you mean bc as the 'calculator that comes with linux', thats somewhat to be expected. Speedcrunch deals with a maximum integer size of 256 bits (~1.15e77), while bc is an arbitrary precision calculator.
I've used it in the past, until one day they removed the buttons/skeuomorphic UI. A couple of years ago, I found it again and is now my daiky driver. It has a newer skeuomorphic interface, which I only use if I can't remember the name of a function.
What I like the most is the seamless integration of different notation styles, mainly using commas and points as decimal separators.
This looks cool! I have been using qalculate (https://qalculate.github.io/) recently, which seems similar. Has anyone used both and can tell me how they compare?
SpeedCrunch is less powerful but I find its interface much easier to understand. SpeedCrunch is really nice. It'd be nice if it was a tad more powerful (for example, to plot quick graphs)
This seems really cool (esp. WRT unit conversions), but I'm already pretty entrenched in using Excel, R, or Python for calculations, since I usually already have one or more of those open. Is it worth learning another tool to pick up something like this?
I find SpeedCrunch can be very useful along side excel once you get a feel for it. Often I use SpeedCrunch's unit conversion and SI prefix features to distill all the magic numbers I need and double check my formula. After that, creating a formula in excell (or another language) to deal convert data in a strange format is easy.
Learning SpeedCrunch is easy if you're already comfortable with single-line calculators. It has autocomplete that will help learn some of the SpeedCrunch specific units. For example, year_julian vs year_tropical, gallon_US vs gallon_UK are slightly different.
That's one of my favourite advantages of free software. No worries about licensing, any computer I pull out of a dumpster gets a full suite of powerful software I'm familiar with.
I just press Cmd-Option-J (or F12 or whatever your browser's hotkey for that is) and the browser's devtools console opens. I can type expressions there.
Nothing beats WA, keep using it. SpeedCrunch is only better when you don't have an internet connection. WA is my default to go calculator, especially after learning its language it's so much powerful than anything
It will treat values as integers by default I think, so $((1/2)) evaluates to zero. But $((1./2)) treats the 1. as something else, I guess probably a float, and so produces .5.
His blog post elicited several rapid responses from developers taking his PyQt-based mockup and turning it into a 'real' application ([2], [3]). One of those was Ariya Hidayat's "SpeedCrunch", which has been actively maintained up to the present day. I can't find Ariya's original 2004 announcement, I think the original link was http://ariya.pandu.org/blog/archives/2004/10/calculator-feve... but that's dead now.
But it's really neat to see how this all started from a day or two of hacking on a solution to a simple problem.
[1] https://ralsina.me/stories/33.html [2] https://ralsina.me/weblog/posts/P245.html [3] https://ralsina.me/weblog/posts/P247.html