Article View: comp.unix.shell
Article #1070Re: bourne shell query
From: George Turczynski
Date: Wed, 05 Sep 1990 06:00
Date: Wed, 05 Sep 1990 06:00
34 lines
1605 bytes
1605 bytes
In article <SCOTT.90Aug30124930@tab00.larc.nasa.gov> scott@tab00.larc.nasa.gov (Scott Yelich) writes:
>As a side question, does ANYONE have any bourne shell routines which do
>math... reasonably effeciently? (For numbers > 1000?)
I don't know whose UNIX you have but you may have a utility called
"dc", for "desk calulator". If you have it, read the man page. It
will handle numbers > 1000 AND numbers with decimal fractions.
for example:
|>---------Cut here----------<|
#! /bin/sh
num="10000.0"
while [ $num != "10010.0" ];
do
num=`echo "$num 0.2 + p" | dc`
echo $num
done
|>---------Cut here----------<|
Just another idea...
--
| George P. J. Turczynski. |----------------------------------------------------
| Computer Systems Engineer. | ACSnet: george@highland.oz | I can't speak for the |
| Highland Logic Pty. Ltd. | Phone: +61 48 683490 | company, I can barely |
| Suite 1, 348-354 Argyle St | Fax: +61 48 683474 | speak for myself... |
| Moss Vale. NSW. Australia. 2577 |----------------------------------------------------
Technical Details
Message-ID:
<925@hls0.hls.oz>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!sdd.hp.com!zaphod.mps.ohio-state.edu!samsung!munnari.oz.au!metro!wolfen!hls0!georgeReferences:
<26DC6447.15922@maccs.dcss.mcmaster.ca> <8446@orca.wv.tek.com> <75@iconsys>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!sdd.hp.com!zaphod.mps.ohio-state.edu!samsung!munnari.oz.au!metro!wolfen!hls0!george From: george@hls0.hls.oz (George Turczynski) Newsgroups: comp.unix.shell Subject: Re: bourne shell query Summary: Use "dc" if you have it. Message-ID: <925@hls0.hls.oz> Date: 5 Sep 90 06:00:42 GMT References: <26DC6447.15922@maccs.dcss.mcmaster.ca> <8446@orca.wv.tek.com> <75@iconsys> Lines: 34