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

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
X-Authentication-Warning: slinky.cs.nyu.edu: pechtcha owned process doing -bs
Date: Fri, 11 Apr 2003 13:59:21 -0400 (EDT)
From: Igor Pechtchanski <pechtcha AT cs DOT nyu DOT edu>
Reply-To: cygwin AT cygwin DOT com
To: Randall R Schulz <rrschulz AT cris DOT com>
cc: cygwin AT cygwin DOT com
Subject: Re: bash and real arithmetic
In-Reply-To: <5.2.1.1.2.20030411104309.02dc8e28@pop3.cris.com>
Message-ID: <Pine.GSO.4.44.0304111356530.26381-100000@slinky.cs.nyu.edu>
Importance: Normal
MIME-Version: 1.0

On Fri, 11 Apr 2003, Randall R Schulz wrote:

> 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
> [snip]
> 0.20
> etc.
> Randall

Yes, yes...  It was an /example/.  If you want leading zeros for numbers
greater than 10, use bash's "printf" builtin:

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

Better? :-p
	Igor
P.S. You're right, though, I should've warned him about it...
-- 
				http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_		pechtcha AT cs DOT nyu DOT edu
ZZZzz /,`.-'`'    -.  ;-;;,_		igor AT watson DOT ibm DOT com
     |,4-  ) )-,_. ,\ (  `'-'		Igor Pechtchanski
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

Knowledge is an unending adventure at the edge of uncertainty.
  -- Leto II


--
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