delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2003/04/11/13:47:03

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Message-Id: <5.2.1.1.2.20030411104309.02dc8e28@pop3.cris.com>
X-Sender: rrschulz AT pop3 DOT cris DOT com
Date: Fri, 11 Apr 2003 10:46:16 -0700
To: cygwin AT cygwin DOT com
From: Randall R Schulz <rrschulz AT cris DOT com>
Subject: Re: bash and real arithmetic
In-Reply-To: <Pine.GSO.4.44.0304111309040.26381-100000@slinky.cs.nyu.edu
>
References: <32202909248 DOT 20030412000235 AT ngs DOT ru>
Mime-Version: 1.0

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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019