|
Home > Archive > Unix Shell > November 2006 > bc vs calc (was bc precision)
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
bc vs calc (was bc precision)
|
|
|
| Does anyone have any comments on bc vs calc (my favorite calculator
program)?
Thanks,
Dave Feustel
| |
|
| dave calc:
> Does anyone have any comments on bc vs calc (my favorite calculator
> program)?
Yes.
calc: not found
>
> Thanks,
> Dave Feustel
| |
| William Park 2006-11-27, 7:23 pm |
| dave <daf@a64.comcast.net> wrote:
> Does anyone have any comments on bc vs calc (my favorite calculator
> program)?
Yes, I didn't write either of them.
--
William Park <opengeometry@yahoo.ca>, Toronto, Canada
ThinFlash: Linux thin-client on USB key (flash) drive
http://home.eol.ca/~parkw/thinflash.html
BashDiff: Super Bash shell
http://freshmeat.net/projects/bashdiff/
| |
|
| in message < SqednVbtiOC6s_fYnZ2dnUVZ_sCdnZ2d@comcast
.com>,
wrote dave ...
> Does anyone have any comments on bc vs calc (my favorite calculator
> program)?
I personally use dc unless I for some unknown reason not start perl
debugger (perl -de42).
(It is not my nature to write the above response to queries like
OP's, but it was hard to avoid after reading previous two replies.)
- parv
--
As nice it is to receive personal mail, too much sweetness causes
tooth decay. Unless you have burning desire to contact me, do not do
away w/ WhereElse in the address for private communication.
| |
|
|
|
| dave wrote:
> Janis <janis_papanagnou@hotmail.com> wrote:
>
> Try http://isthe.com/chongo/tech/comp/calc/.
Thank's for the link. But it's no option for me to use any other tool
that is not generally available on any Unix system I work on. You can
expect 'bc' to be available. Portability is an issue.
Janis
| |
|
| Janis <janis_papanagnou@hotmail.com> wrote:
> dave wrote:
>
> Thank's for the link. But it's no option for me to use any other tool
> that is not generally available on any Unix system I work on. You can
> expect 'bc' to be available. Portability is an issue.
>
> Janis
I have downloaded and built calc on OpenBSD. Calc is included as a
pre-built package on OpenBSD and probably on the other BSD's as well.
Dave
| |
|
| dave wrote:
> Janis <janis_papanagnou@hotmail.com> wrote:
>
> I have downloaded and built calc on OpenBSD. Calc is included as a
> pre-built package on OpenBSD and probably on the other BSD's as well.
Fine. So what?
My first reply to your "my favorite calculator" statement might
have been too brief to understand why it is a problem to rely
on non-standard tools. You seem to assume that on whatever
machine you want you may install whatever tool you like. Real
Life is different.
Janis
| |
| Kenny McCormack 2006-11-28, 1:17 pm |
| In article <1164732572.222070.82070@j44g2000cwa.googlegroups.com>,
Janis <janis_papanagnou@hotmail.com> wrote:
....
>My first reply to your "my favorite calculator" statement might
>have been too brief to understand why it is a problem to rely
>on non-standard tools. You seem to assume that on whatever
>machine you want you may install whatever tool you like. Real
>Life is different.
Maybe you need to trade your life in on new and better one.
Seriously - if you *can't* install your own tools, then you're living in
a box.
| |
| Loki Harfagr 2006-11-28, 1:17 pm |
| Le Sun, 26 Nov 2006 18:15:35 -0600, dave a écrit_:
> Does anyone have any comments on bc vs calc (my favorite calculator
> program)?
>
Using bc saves a lot of typing, half letters free !-)
Now, I mostly use bc, that's for portability reasons, as Janis
already stated, though on my *own* (not contractors or caged) I
sometimes have the use for a different level stuff then I don't
know much about 'calc' but I use 'mathomatic' which you may like
to try if you're looking for a competitor to 'calc' :D)
http://mathomatic.orgserve.de/math/
But this is not much on topic for 'c.u.shell' so I rest my case ;-)
| |
| Janis Papanagnou 2006-11-28, 1:18 pm |
| Kenny McCormack wrote:
> In article <1164732572.222070.82070@j44g2000cwa.googlegroups.com>,
> Janis <janis_papanagnou@hotmail.com> wrote:
> ...
>
>
>
> Maybe you need to trade your life in on new and better one.
???
In Europe, where I live, even sysadmins seem nowadays not to be
allowed to do what they like on their company's machines. I've
heard similar things from the US of America. It may be different
where you live and work.
> Seriously - if you *can't* install your own tools, then you're living in
> a box.
"can not" != "may not".
On _my own_ boxes I can do anything I like, but that was not the
point.
Janis
| |
| Chris F.A. Johnson 2006-11-28, 7:24 pm |
| On 2006-11-27, William Park wrote:
> dave <daf@a64.comcast.net> wrote:
>
> Yes, I didn't write either of them.
I *did* write calc; it's a shell function. I think I've posted it
here before (and it is in my book). It's probably not the calc that
Dave is referring to, but there are many programs with that name,
so it's impossible to say what he means.
--
Chris F.A. Johnson, author <http://cfaj.freeshell.org/shell>
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
===== My code in this post, if any, assumes the POSIX locale
===== and is released under the GNU General Public Licence
| |
| Loki Harfagr 2006-11-29, 7:22 pm |
| Le Tue, 28 Nov 2006 18:16:02 -0500, Chris F.A. Johnson a écrit_:
> On 2006-11-27, William Park wrote:
>
> I *did* write calc; it's a shell function. I think I've posted it
> here before (and it is in my book). It's probably not the calc that
> Dave is referring to, but there are many programs with that name,
> so it's impossible to say what he means.
Now that I think about this I also did write 'calc' though it was circa
1981 and an APL function I wrote to provide infinite precision calculus,
that was quite painful in performances as it ran in a 32 to 64 KB
"WorkSpace" on a PDP-10 running Tymshare, after browsing the link provided
by the OP I can certify hereby that it is *not* the same one ;D)
| |
| Kaz Kylheku 2006-11-30, 1:33 am |
| dave wrote:
> Does anyone have any comments on bc vs calc (my favorite calculator
> program)?
Just this: learn a real programming language. ANSI Common Lisp.
The CLISP implementation (clisp.cons.org) is good for interactive use,
including as a desktop calculator, if you wish.
Calc is a pale imitation that pales by comparison: evidence of
Greenspun's Tenth Rule of programming hard at work.
This session touches on some diversity you can find:
First, a simple demonstration of the foreign function interface, by
means of which we gain access into the libc ABI to call the strerror
function. Much more complex things are possible. Then some numeric
computing with bignums, rationals and complex numbers.
In Lisp, the square root of -1 is properly a complex number. When two
rationals add to an integer, an integer type comes out.
Then we use the LOOP macro to extract error strings from libc, and make
them into a list, which we then filter using MAPCAR to upcase
everything, then reverse the strings instead.
Then we get bored and end the article. But not before showing how LOOP
is actually a macro written in Lisp which performs syntactic
transformation to do its job.
No time for the object system with multiple dispatch, auxiliary
methods, programmable method combinations, meta-object protocol. Nor
for the condition system, restarts, special variables, lexical
closures, vectors and structs, symbols, packages, the streams library,
gray streams, CLISP's character encoding library, read macros, FORMAT,
destructuring-bind, ... and on and on.
CLISP has a fast bignum library, it's very good for bignum
computations; better than natively compiling Lisp implementations, even
though it only compiles to byte code. It would be interesting to
benchmark CLISP and calc on the same problems.
Psst. Don't tell Janis.
0:localhost:~/lisp$ clisp -q
[1]> (use-package :ffi)
T
[2]> (def-call-out strerror (:language :stdc) (:library "libc.so.6")
(:arguments (errnum int)) (:return-type c-string))
STRERROR
[3]> (strerror 13)
"Permission denied"
[4]> (strerror 0)
"Success"
[5]> (strerror 22)
"Invalid argument"
[6]> (expt 19 56)
4075694781729098288473186505484201534178
75032325531352984650263038054881
[7]> (/ 123 57)
41/19
[8]> (- (/ 123 57) 3/19)
2
[9]> (sqrt -1)
#C(0 1)
[10]> (sqrt -1.0)
#C(0 1.0)
[11]> (cosh #c(-1 -1))
#C(0.83373004 0.9888977)
[12]> (loop for x below 32 collecting (strerror x))
("Success" "Operation not permitted" "No such file or directory" "No
such process"
"Interrupted system call" "Input/output error" "No such device or
address"
"Argument list too long" "Exec format error" "Bad file descriptor" "No
child processes"
"Resource temporarily unavailable" "Cannot allocate memory"
"Permission denied" "Bad address"
"Block device required" "Device or resource busy" "File exists"
"Invalid cross-device link"
"No such device" "Not a directory" "Is a directory" "Invalid argument"
"Too many open files in system" "Too many open files" "Inappropriate
ioctl for device"
"Text file busy" "File too large" "No space left on device" "Illegal
seek"
"Read-only file system" "Too many links")
[13]> (mapcar #'string-upcase (loop for x below 32 collecting (strerror
x)))
("SUCCESS" "OPERATION NOT PERMITTED" "NO SUCH FILE OR DIRECTORY" "NO
SUCH PROCESS"
"INTERRUPTED SYSTEM CALL" "INPUT/OUTPUT ERROR" "NO SUCH DEVICE OR
ADDRESS"
"ARGUMENT LIST TOO LONG" "EXEC FORMAT ERROR" "BAD FILE DESCRIPTOR" "NO
CHILD PROCESSES"
"RESOURCE TEMPORARILY UNAVAILABLE" "CANNOT ALLOCATE MEMORY"
"PERMISSION DENIED" "BAD ADDRESS"
"BLOCK DEVICE REQUIRED" "DEVICE OR RESOURCE BUSY" "FILE EXISTS"
"INVALID CROSS-DEVICE LINK"
"NO SUCH DEVICE" "NOT A DIRECTORY" "IS A DIRECTORY" "INVALID ARGUMENT"
"TOO MANY OPEN FILES IN SYSTEM" "TOO MANY OPEN FILES" "INAPPROPRIATE
IOCTL FOR DEVICE"
"TEXT FILE BUSY" "FILE TOO LARGE" "NO SPACE LEFT ON DEVICE" "ILLEGAL
SEEK"
"READ-ONLY FILE SYSTEM" "TOO MANY LINKS")
[14]> (mapcar #'reverse (loop for x below 32 collecting (strerror x)))
("sseccuS" "dettimrep ton noitarepO" "yrotcerid ro elif hcus oN"
"ssecorp hcus oN"
"llac metsys detpurretnI" "rorre tuptuo/tupnI" "sserdda ro ecived hcus
oN"
"gnol oot tsil tnemugrA" "rorre tamrof cexE" "rotpircsed elif daB"
"sessecorp dlihc oN"
"elbaliavanu yliraropmet ecruoseR" "yromem etacolla tonnaC" "deined
noissimreP" "sserdda daB"
"deriuqer ecived kcolB" "ysub ecruoser ro eciveD" "stsixe eliF" "knil
ecived-ssorc dilavnI"
"ecived hcus oN" "yrotcerid a toN" "yrotcerid a sI" "tnemugra dilavnI"
"metsys ni selif nepo ynam ooT" "selif nepo ynam ooT" "ecived rof
ltcoi etairporppanI"
"ysub elif txeT" "egral oot eliF" "ecived no tfel ecaps oN" "kees
lagellI"
"metsys elif ylno-daeR" "sknil ynam ooT")
[15]> (macroexpand '(loop for x below 32 collecting (strerror x)))
(MACROLET ((LOOP-FINISH NIL (SYSTEM::LOOP-FINISH-ERROR)))
(BLOCK NIL
(LET ((X 0))
(PROGN
(LET ((#:ACCULIST-VAR-2970 NIL))
(MACROLET ((LOOP-FINISH NIL '(GO SYSTEM::END-LOOP)))
(TAGBODY SYSTEM::BEGIN-LOOP (WHEN (>= X 32) (LOOP-FINISH))
(PROGN (SETQ #:ACCULIST-VAR-2970 (CONS (STRERROR X)
#:ACCULIST-VAR-2970)))
(PSETQ X (+ X 1)) (GO SYSTEM::BEGIN-LOOP) SYSTEM::END-LOOP
(MACROLET ((LOOP-FINISH NIL (SYSTEM::LOOP-FINISH-WARN) '(GO
SYSTEM::END-LOOP)))
(RETURN-FROM NIL (SYSTEM::LIST-NREVERSE
#:ACCULIST-VAR-2970)))))))))) ;
T
| |
| Chris Mattern 2006-11-30, 1:17 pm |
| In article <ekhums$94f$1@news.xmission.com>, Kenny McCormack wrote:
>In article <1164732572.222070.82070@j44g2000cwa.googlegroups.com>,
>Janis <janis_papanagnou@hotmail.com> wrote:
>...
>
>Maybe you need to trade your life in on new and better one.
>
>Seriously - if you *can't* install your own tools, then you're living in
>a box.
>
Yes. A production box. That's how it real life works.
--
Christopher Mattern
"Which one you figure tracked us?"
"The ugly one, sir."
"...Could you be more specific?"
|
|
|
|
|