There have been lots of times in the past where a good programmer-oriented calculator would've saved me a lot of time. Lately, I've been doing quite a lot of bit manipulation, and having to do build/run to debug my calculations feels really slow. I've looked for something like this in the past, but found nothing that worked very well. The only thing that comes close is this one from AnalogX, but I can't get it to work or really do anything on my vista box which is where I'm doing most of my work at the moment. (btw - please send comments about my vista usage here;).
Anyway, I'm looking for something for simple calculations using a C-like syntax with support for proper precenedce, operators, etc. Bonus points for cross-platform.
The python interpreter was a great idea and is totally cross-platform. For windows only SpeQ is amazing. Thanks for the suggestions.
-
Whenever I need calculator-type stuff I just fire up the python interpreter. In fact, the python tutorial has a chapter which uses its calculator-like functions to introduce the language. The startup time is about 2s on my old n' busted laptop.
EDIT: and since you are interested in bit manipulation, note that the built-in
hex()
function will spit out the argument represented in hexadecimal.AdamC : very interesting - checking it out now. thanksAaron Maenpaa : +1 on using the python interpreter.AdamC : cool - thanks. this works great. vista was fighting the installer, so I'm using it through my linux box.Daok : Python work great on my Vista 64 bits.J.F. Sebastian : You could add that Python has binary literals: 0b101010J.F. Sebastian : IPython is the shell for Python: http://ipython.scipy.org/moin/Daren Thomas : Try out Reinteract! It is a shell for python that should make python an ideal calculator!!!From Ryan -
An interactive Python shell works great as a calculator. It has all of the usual operators, although instead of overflowing integers, it automatically converts overflowed calculations into longs (i.e. bignums).
From Adam Rosenfield -
I use "bc -l". Works on Linux, all flavours of Unix and Mac OS X.
fbrereto : It'd be _perfect_ if `bc` could do base conversions, too...Paul Tomblin : @fbrereto, look up "ibase", "obase" in the bc man page.fbrereto : @Paul, cool, thanks!From Paul Tomblin -
PCalc is what I use.
From Paul Nathan -
I've been using SpeQ, might fit your needs:
http://www.speqmath.com/index.php?id=1
AdamC : This is really cool. thanksFrom ChalkTrauma -
Being a happy owner of first HP48G and now HP50g calculators, I came to love RPN and stack. The closest thing to such calculator that I've found on a PC is emacs calculator (bundled with emacs 22 or greater).
From zvrba -
If you want a calculator with C-like syntax and precedence, I'd recommend gdb (GNU Debugger).
bk1e : Why vote this down? This answer could use more explanation, but it's not fundamentally wrong or unhelpful.Software Monkey : @bk1e: I agree; I really wish downvotes required you to add a reason (even an anonymous one).JesperE : There is a uservoice ticket for this: http://stackoverflow.uservoice.com/pages/general/suggestions/41056-force-user-to-comment-on-downvoteFrom JesperE -
For programmers I think Stack Oriented languages can be a great tool.
Several such languages let you use Reverse Polish Notation (RPN) for specifying accurate evaluation order without brackets.
Forth is one such language with several implementations and interactive interpreters for several platforms.
The downside of using it off-course is you cannot simply copy-paste the code into your programs in C like languages that use infix notation. But I think a simple function can be written in Forth to spit-out an infix formatted expression.
BTW, my personal favorites are spread sheet programs like MS Excel or Open Office Calc.
From Tahir Akhtar -
Speedcrunch springs to mind. Sadly, I don't think it lets you define functions in the normal input. But it supports variables and has a wide range of builtins.
If you want something more scientific/hard-core, there is always GNU Octave. Several windows ports can be found on wiki.octave.org.
Edit: typo
From gnud -
You may laugh (or downvote me into oblivion), but you can actually do logical operations (AND, OR, NOT, XOR) on numbers in binary, hex, etc. using the fantastic......Windows calculator!
WolfmanDragon :But that would not be geeky enough. bk1e : I didn't buy a Microsoft Ergonomic keyboard for the application buttons (home, search, mail, etc.), and I find them to be mostly superfluous. However, I have to admit that I use the calculator button all of the time.Electrons_Ahoy : Man, I use the Windows Calculator for stuff like this *every day.* And here I thought I was the only one!Software Monkey : So do I - the View/Scientific option is a wonderful thing!Aardvark : Windows 7's calc even has a "programmer" mode...NealB : Windows bashing is always fun, but I give them high marks for their scientific/programmer calculator.Ian : The Windows 7 calc "programmer mode" is exactly why I searched for this thread... apparently the writers were under the assumption that programmers do not use decimals...From Don -
The PowerShell command prompt is an alternative to Python for the Windows .Net developer. Using the System.Math namespace, you have lots of functions to play with. Add in the PowerTab extensions and you have (almost) Intellisense as well.
A degree of portability is available via Pash (PowerShell open source reimplementation for "others" - Mac, Linux, Solaris, etc...)
From Dan Blanchard -
For this kind of thing I use the Firebug console. For hex or (any other base), use number.toString(16)
From harpo -
A few more calculator replacements that come to mind:
Ruby's
irb
moduleirb
is an interactive interpreter for the Ruby language.irb(main):001:0> printf "%#08x\n", 0xdeadbeef & (~0<<16) 0xdead0000 => nil irb(main):002:0>
GDB (The GNU Project Debugger)
As suggested by JesperE, GDB has an interactive expression evaluator that supports C-like syntax.
(gdb) printf "%#08x\n", 0xdeadbeef & (~0<<16) 0xdead0000 (gdb)
WinDbg (The Windows Debugger)
Like GDB, the Debugging Tools for Windows debuggers (WinDbg, NTSD, etc.) have an interactive expression evaluator that supports C-like syntax. Unlike GDB, they are Windows-specific. Also unlike GDB, you have to choose something to debug, but opening up an ordinary EXE like
notepad.exe
as a crash dump (using the menu or the-z
option) will let you use the expression evaluator without starting a new notepad process.0:000> ?? 0xdeadbeef & (~0<<16) unsigned int 0xdead0000 0:000>
GNU Octave is an interpreted language for mathematical calculations. Its syntax isn't very C-like, but it has support for matrix math and graphing.
Microsoft Excel
For some situations, a spreadsheet is the best calculator replacement.
From bk1e -
instacalc is an online calculator. It supports a lot of scientific/programmer calculations including the bitwise operations:
and or xor not << >>
(see the drop down box where it says Basic Math) and can do line/bar charts. And once you've got your calculation worked out it's easy to share.From Sam Hasler -
Graphcalc is another option. There appears to be a Linux version also, but I haven't used it. Source code is provided for both editions.
From Philip T. -
I've used sage for a lot of this stuff (since it's essentially a python interpreter). There's even a free online version.
From Jason Baker -
I use Matlab. You can use it for almost anything. It's a bit heavier, but being able to call an optimization tool box quickly is nice.
MaSuGaNa : Matlab is the overlord of calculators! :)From ccook -
I'm surprised that no one has mentioned Emacs Calc yet. Cross platform, built into my favorite editor, and easily handles anything I throw at it.
From Boojum -
One of the first things I download on a fresh install is SuperCalc from James Brown's (fantastic) site http://www.catch22.net/
It takes up literally no real estate and it works great for my purposes.
From Sean Bright -
Just and FYI, it looks like there's been an update to AnalogX's pcalc that might fix the issues with running under Vista, so you might want to give it another try.
It's my favourite little quick and dirty calculator too (even managed to get it working under WINE!)
AdamC : thanks - I'll check it out.From Evan -
Use google!
Ascalonian : Check out: http://www.googleguide.com/calculator.htmlFrom Nick -
PowerCalc is good if you are on Windows. It also has a nifty graphing ability.
From scottm -
GNU octave - it runs on linux natively, has mac binaries, and can run on windows using cygwin. It is supposed to be like matlab - so you can pretty much do any kind of operation you want using it. http://www.gnu.org/software/octave/index.html
From nick -
I like Wolfram Alpha. Want to see how much data would be taken up, by, say, the population of the United States if every person required 1 MB? Instead of taking an extra step to look up the population, just search for "1 megabyte * population of united states"!
From RarrRarrRarr -
This may sound sad, but I miss bc (http://www.gnu.org/software/bc/) on the unix platform sometimes.
That little app was a workhorse.
From vfilby -
I can't believe no-one mentioned PARI/GP
From st0le
0 comments:
Post a Comment