Re: Bash decimal arithmetic?

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

 



On Wed, Nov 10, 2004 at 10:18:32PM -0500, Graham Campbell 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.

Alternatively, scale your numbers. i.e. if you need two decimal
places, run everything internally as integers 100 times the "real"
value, and display with the decimal point in the correct place. Old
assembly language programmers' trick.

-- 

Charles Curley                  /"\    ASCII Ribbon Campaign
Looking for fine software       \ /    Respect for open standards
and/or writing?                  X     No HTML/RTF in email
http://www.charlescurley.com    / \    No M$ Word docs in email

Key fingerprint = CE5C 6645 A45A 64E4 94C0  809C FFF6 4C48 4ECD DFDB

Attachment: pgpPo5ucpHya7.pgp
Description: PGP signature


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

  Powered by Linux