Gentoo Archives: gentoo-user

From: jarry@×××.net
To: gentoo-user@l.g.o
Subject: [gentoo-user] OT: bash & decimal/exponential numbers math...
Date: Tue, 22 Nov 2005 11:42:05
Message-Id: 21449.1132659142@www39.gmx.net
1 Hi,
2
3 I wrote a short script for simple text file processing in bash
4 (using "<" for input redirection and "read"). I know, there are
5 probably better tools to do it, but the only thing I can rely on
6 being installed on target comp is really bash and nothing more
7 (no bc, sed, awk, etc.) so I must use only its built-in functions.
8
9 Everything would be OK, if there were only positive integer numbers
10 in that input file. Unfortunatelly, there are also decimal and
11 exponential numbers (like 123.456 or 1.23456e+02) which my script
12 must process. Now I'm pretty deadlocked because too late I realised
13 that very basic math functions of bash can not handle such numbers.
14
15 Now what to do? Are there some functions, which would implement basic
16 math with real numbers in bash (add, substract, multiply, divide
17 and round would be enough)?
18 The idea of writing them myself really scares me...
19
20 Jarry
21
22 --
23 10 GB Mailbox, 100 FreeSMS/Monat http://www.gmx.net/de/go/topmail
24 +++ GMX - die erste Adresse für Mail, Message, More +++
25 --
26 gentoo-user@g.o mailing list

Replies

Subject Author
Re: [gentoo-user] OT: bash & decimal/exponential numbers math... "Anthony E. Caudel" <acaudel@×××××.com>