Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: strange arithmetic
- X-seq: zsh-users 1161
- From: Alain Caron <alainc@xxxxxxxxxxxxx>
- To: mito@xxxxxxxxxxx
- Subject: Re: strange arithmetic
- Date: Fri, 28 Nov 1997 15:16:37 -0500
- Cc: zsh-users@xxxxxxxxxxxxxxx
- Organization: Sanga Research Corporation
- References: <19971128140924.07137@retriever>
- Sender: alainc@xxxxxxxxxxxxxxxxxxxxx
Louis-David Mitterrand wrote:
> (using 3.0.5)
>
> % i=0;while [[ $[++i] < 900 ]];do;echo $i;done
> % 1
> % 2
> [...]
> % 90
>
> 90 ?? I asked for 900 and it stops at 90. On the other hand the
> following:
>
> % i=0;while ! [[ $[++i] = 900 ]];do;echo $i;done
> % 1
> % 2
> [...]
> % 899
>
> Is this normal?
>
> --
>
> Louis-David Mitterrand
> http://www.aparima.com
> mito@xxxxxxxxxxx
This is, I presume, because ">" and "=" are doing a lexicographic
comparison. For a numeric
comparison, use "-gt" and "-eq" operators.
Alain Caron
alainc@xxxxxxxxxxxxx
Messages sorted by:
Reverse Date,
Date,
Thread,
Author