You are not logged in.

#1 2012-03-08 00:09:58

ehmicky
Member
Registered: 2012-02-07
Posts: 10

[Solved]Looking for a good command-line calculator

Hey guys,

I'm looking for a good command-line calculator, like bc. I find bc quite limited as is (even with user-defined functions) : for example, I can't calculate logarithms for any base or powers of rational numbers (like 2^2.5). I might calculate log(x) / log(y) to get a log(x) of base y. And 2^2.5 = √2^5. But I'd like my calculator to think about it by itself big_smile and not getting a runtime error when I try to calculate those things.
I had to emulate all of those, by creating a wrapper taking the input from the terminal, parsing it and calculating those things with my own small programs, and then giving the output to bc. But it's hardly maintainable as you imagine !
So I'm looing for a better command-line calculator, does anyone know one ? (no polish notation, it quite confuses me smile )
Thanks !

Last edited by ehmicky (2012-03-08 01:01:50)


Stego++, first general-purpose steganography library ever !
Will use most-used steganographic techniques as modules, with crypto and compression support, and high-quality security features. LGPL.
Release by end 2012. Contact me if you know crypto or stego and would be interested in team working with me.

Offline

#2 2012-03-08 00:18:33

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [Solved]Looking for a good command-line calculator

Offline

#3 2012-03-08 00:23:31

firecat53
Member
From: Lake Stevens, WA, USA
Registered: 2007-05-14
Posts: 1,542
Website

Re: [Solved]Looking for a good command-line calculator

I actually use the python command line for most of my basic arithmetic needs. A simple 'import math' then gives you access to a ton of math functions (such as log) and a fairly friendly command line.

Scott

Offline

#4 2012-03-08 00:59:37

ehmicky
Member
Registered: 2012-02-07
Posts: 10

Re: [Solved]Looking for a good command-line calculator

Hey,
Thanks for your replies.
calc is really great, I'm gonna use it I think, although I still need to parse the input, cause I configured my keyboard with crazy keys like √,℮,∫,ℕ or ± that calc doesn't handle big_smile
I've bumbed into another calculator called genius, which looks also awesome, with crazy things like number theory functions I have no idea what they're about smile
Thank you very much !

Last edited by ehmicky (2012-03-08 01:02:12)


Stego++, first general-purpose steganography library ever !
Will use most-used steganographic techniques as modules, with crypto and compression support, and high-quality security features. LGPL.
Release by end 2012. Contact me if you know crypto or stego and would be interested in team working with me.

Offline

#5 2012-03-08 02:50:25

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 20,615

Re: [Solved]Looking for a good command-line calculator

As a devoted reverse Polish guy, How about bc or orpie ?

And then I re-read your first post sad


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
The shortest way to ruin a country is to give power to demagogues.— Dionysius of Halicarnassus
---
How to Ask Questions the Smart Way

Offline

#6 2012-03-08 10:17:30

makimaki
Member
From: Ireland
Registered: 2009-04-02
Posts: 109

Re: [Solved]Looking for a good command-line calculator

...
So I'm looing for a better command-line calculator, does anyone know one ? (no polish notation, it quite confuses me smile )
...


Try awk, for simple things you can write a script that passes arguments to awk, it's also faster to load than python and almost all *nix systems should have it installed which I find very useful.
To get awk to print out the results of a calcuation it should be of the following form

awk 'BEGIN{print 3/2}'

You can also try this tutorial


====* -- Joke
    O
    \|/ --- Me
    / \             Whooooosh

Offline

#7 2012-03-08 10:22:42

cra
Member
From: Sweden
Registered: 2009-09-25
Posts: 70

Re: [Solved]Looking for a good command-line calculator

Don't do that. Don't go awk. Use bc for small calculations (better alias bc="bc -l -q") and pcalc for programming stuff. If you need anything more complicated, you can always go with maxima


Thou shalt not make a machine in the likeness of a human mind

Offline

#8 2012-03-08 10:48:59

makimaki
Member
From: Ireland
Registered: 2009-04-02
Posts: 109

Re: [Solved]Looking for a good command-line calculator

cra wrote:

Don't do that. Don't go awk. Use bc for small calculations (better alias bc="bc -l -q") and pcalc for programming stuff. If you need anything more complicated, you can always go with maxima

I disagree, awk is more portable, and it's reasonably fast. More systems have awk than bc, dc or maxima because it is part of the uinix spec so you can be guaranteed to find awk and bash on any *nix system you work on. He also said he no longer wishes to use bc because of its limitations, awk is a good replacement for the simple command line calculations that he is interested in without having to wait for larger programs to load.


====* -- Joke
    O
    \|/ --- Me
    / \             Whooooosh

Offline

#9 2012-03-08 10:49:05

skanky
Member
From: WAIS
Registered: 2009-10-23
Posts: 1,847

Re: [Solved]Looking for a good command-line calculator

A bit late, but another suggestion is wcalc https://aur.archlinux.org/packages.php?ID=15219
It should do all you want, but I don't use it for anything too sophisticated, so I can't say it fulfils all your criteria.


"...one cannot be angry when one looks at a penguin."  - John Ruskin
"Life in general is a bit shit, and so too is the internet. And that's all there is." - scepticisle

Offline

#10 2012-03-08 10:52:01

skanky
Member
From: WAIS
Registered: 2009-10-23
Posts: 1,847

Re: [Solved]Looking for a good command-line calculator

makimaki wrote:
cra wrote:

Don't do that. Don't go awk. Use bc for small calculations (better alias bc="bc -l -q") and pcalc for programming stuff. If you need anything more complicated, you can always go with maxima

I disagree, awk is more portable, and it's reasonably fast. More systems have awk than bc, dc or maxima because it is part of the uinix spec so you can be guaranteed to find awk and bash on any *nix system you work on. He also said he no longer wishes to use bc because of its limitations, awk is a good replacement for the simple command line calculations that he is interested in without having to wait for larger programs to load.

awk yes, bash, no. I know people who work on systems without bash. [/pedantry] smile


"...one cannot be angry when one looks at a penguin."  - John Ruskin
"Life in general is a bit shit, and so too is the internet. And that's all there is." - scepticisle

Offline

#11 2012-03-08 11:10:03

makimaki
Member
From: Ireland
Registered: 2009-04-02
Posts: 109

Re: [Solved]Looking for a good command-line calculator

skanky wrote:

awk yes, bash, no. I know people who work on systems without bash. [/pedantry] smile

Then it's either embedded systems, e.g. ash, or the default is different like tcsh on FreeBSD, but it should still be there, even on FreeBSD, unless the admin removed it deliberately. By default almost all *nix systems have bash or a bash-like shell available. The previous institute I worked in used tcsh but bash was available.

smile

Edited for return friendly smiley face - I forget tone gets lost and short posts can sound unfriendly

Last edited by makimaki (2012-03-08 11:12:46)


====* -- Joke
    O
    \|/ --- Me
    / \             Whooooosh

Offline

#12 2012-03-08 11:48:51

skanky
Member
From: WAIS
Registered: 2009-10-23
Posts: 1,847

Re: [Solved]Looking for a good command-line calculator

They are large Unix systems and only have ksh available. This may be an exception (tbh I have no idea how common it may be) but it's at least two large companies involved in the systems. You're right though in that some reasonable shell will pretty much be available now, even if it's not bash per se in every case. I was just being unhelpfully pedantic (it's been a slow morning). Apologies for the digression. smile


"...one cannot be angry when one looks at a penguin."  - John Ruskin
"Life in general is a bit shit, and so too is the internet. And that's all there is." - scepticisle

Offline

#13 2012-03-08 12:11:43

ehmicky
Member
Registered: 2012-02-07
Posts: 10

Re: [Solved]Looking for a good command-line calculator

Hi all,
Thanks for the tips. wcalc is also a good answer for my request, although it's a bit simpler/more limited that genius or calc. For example, it seems like it doesn't support complex numbers or matrix calculation.

Last edited by ehmicky (2012-03-08 12:12:21)


Stego++, first general-purpose steganography library ever !
Will use most-used steganographic techniques as modules, with crypto and compression support, and high-quality security features. LGPL.
Release by end 2012. Contact me if you know crypto or stego and would be interested in team working with me.

Offline

Board footer

Powered by FluxBB