This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: bash and real arithmetic


At 10:21 2003-04-11, Igor Pechtchanski wrote:
On Sat, 12 Apr 2003, Stepan Yakovenko wrote:

> HI!
>
>   Is it possible to get for loops working
>   in double arithmetic in bash ? I've got to run
>   a program with a real argument many times, changing it
>   every run by some fixed small (<1) number.
>
>   Thanx in advance, sorry for my broken English.

Umm, scale? For example:

for (( i=0; i < 10; i++ )); do echo 0.$i; done

Umm, leading zero suppression?


% for (( i=0; i < 100; i++ )); do echo 0.$i; done

0.0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
0.10
0.11
0.12
0.13
0.14
0.15
0.16
0.17
0.18
0.19
0.20

etc.


You could also try using something like awk for driving the loop:

awk 'BEGIN {for (i=0; i < 1; i+=0.1) system("echo " i)}' < /dev/null

Hope this helps,
    Igor


Randall


-- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]