6 ms·
In the past when I needed a calculator on someone’s Mac, I just started Python in a terminal and typed in expressions to be evaluated. It was nice to be able to
by todd8 7y ago
In the past when I needed a calculator on someone’s Mac, I just started Python in a terminal and typed in expressions to be evaluated. It was nice to be able to find it on any Mac and it’s much nicer to type into Python’s REPL than clicking on a calculator’s GUI buttons. Now, Windows machines
will have Python and
Macs may not.
On Macs and Linux I can still use the bc command instead (it’s an old Unix command) but it’s far less handy than Python. See the bc man page.
There’s also dc, the even less used, reverse Polish notation calculator. It is a standard Unix command that predates bc.
Interestingly, the dc “language” is older than C, Awk, Perl, or any other programming language still found on Unix systems. It is implemented in C’s predecessor, the language B.
You can tell that bc and dc are early Unix commands from their names, many of the oldest Unix commands are just two characters long.
- j0e1 7y agoI like how this is also your bio (about)!
- ygra 7y agoFor me on Windows that quick command-line calculator has been PowerShell for a while.
- dullgiulio 7y agoOr bash, just $((1+1)).
- yegle 7y agoThis is presumably integer calculation only?
- slig 7y agoFWIW, macOS has Spotlight Search and it works as a calculator as well. (⌘+SPACE to activate it).
- todd8 7y agoI use spotlight a lot, but never for calculations. I’ll have to try that out. The ability to use variables, math functions, lists, loops, and completion in Python will likely keep me using it as my basic calculator. Although I need to figure out a way to edit my REPL history to fix typos better.
- coldtea 7y ago>In the past when I needed a calculator on someone’s Mac, I just started Python in a terminal and typed in expressions to be evaluated (...) The ability to use variables, math functions, lists, loops, and completion in Python will likely keep me using it as my basic calculator. Why do you do math on random people's laptops?
- todd8 7y agoTech support for family, friends, coworkers.
- coldtea 7y agoI do all that too, it rarely, if ever, involves math. Installing this, formatting that, removing some virus, installing some hardware, configuring the OS or a program yes.
- todd8 7y agoYes, a lot of the tech support falls into your enumeration, but I was Chief Scientist at a company for over six years, an OS Architect at IBM for five years and subsequently have done years of part time consulting at a number of startups. It's not unusual to be in someone's office or even having coffee with my daughter (she studying engineering) when some question that involves simple calculations comes up, things like "Is this algorithm warranted given the data set size?". One of my degrees is in math and perhaps this leads me to think quantitatively about many questions. In my own office I use perhaps a dozen machines. Servers running FreeBSD, OpenBSD, or Linux. Linux, Windows, and Mac desktops and laptops. Few are actually set up as Python development machines (those of course have recent Python installed), but having a ubiquitous tool for simple calculations (or even short scripts) is quite handy on all of the others. My work might not be typical: I have been programming for over half a century and I started making use of Python for simple programs in the Python 1.2 time frame around 20 years ago. I'm not really a Python developer, but I appreciate it as a useful tool--even as a keyboard driven calculator.
- acomjean 7y agoI always use bc -l, as it gives more digits in the reply. Also available on macs/linux and most unixes. e.g.: $echo '1/2' | bc 0 $ echo '1/2' | bc -l .50000000000000000000 though honestlyI usually just type bc -l you enter into an interactive calculator similar to python.
- tgb 7y agoIt's not actually on Windows default installs though, it's just more easily installable. So not much help in your situation. Google will do arithmetic for you, that's often the quickest.
- cheeze 7y agoI do this on the js console in the browser
- beatgammit 7y agoWhat's sad is that JavaScript isn't a very convenient language for this type of thing, but it's available (Math.pow(x, y) instead of x \\ y, limited integer accuracy, etc). I usually use the Python REPL, but occasionally I use the browser, it's just so ubiquitous.
- yokohummer7 7y agoWait, how do they build dc? Is there a B compiler for 64-bit systems?
- jrockway 7y agodc has been my preferred calculator forever. I think I tried to use bc but couldn't figure out the syntax, whereas dc was very clear.
- afiori 7y agoPython3 will still be available