Re: Bash decimal arithmetic?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 22:18 10 Nov 2004, Graham Campbell <gc1111@xxxxxxxxxxxxx> wrote:
| On Wed, 2004-11-10 at 21:22 -0500, Dean Maluski wrote:
| > Does bash have an option to do non integer math in scripts?
| > I need my exact decimal numbers.
| 
| An "exact decimal number" is a contradiction in terms. If you can
| specify the precision you wish to retain then use bc to do the
| calculations.

Of course, an "exact decimal number" is not a contradiction in terms.
2.5 is exactly 2.5. or course, _some_ decimal numbers are not storable
precisely in the _default_ internal binary format usually used for floats,
but that doesn't make the noption nonsensical.

But I'll second the suggestion that you use "bc" to do the work,
possibly/probably controlled from a shell script.

Cheers,
-- 
Cameron Simpson <cs@xxxxxxxxxx> DoD#743
http://www.cskk.ezoshosting.com/cs/

Gentle suggestions being those which are written on rocks of less than 5lbs.
        - Tracy Nelson in comp.lang.c


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux