Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
RE: question about float variables
- X-seq: zsh-users 4369
- From: Borsenkow Andrej <Andrej.Borsenkow@xxxxxxxxxxxxxx>
- To: "'Phil Pennock'" <Phil.Pennock@xxxxxxxxxxx>
- Subject: RE: question about float variables
- Date: Wed, 10 Oct 2001 14:10:23 +0400
- Cc: "'Bruno Bonfils'" <asyd@xxxxxxxxxxxxx>, "'ZSH Users'" <zsh-users@xxxxxxxxxx>
- Importance: Normal
- In-reply-to: <20011010114224.A12923@xxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
>
> > Integer divided by integer is integer.
>
> Not so useful if you're manipulating parameters and you don't know
what
> their value is in advance.
>
Sigh ... zsh was meant to be used for arithmetic computations. Obvious
workarounds are
- multiply by 1.0: $((var1*1.0/var2))
- use temps
- use float() function: $((float(var1)/var2))
What is wrong with above?
BTW how is it different from C?
#include <stdio.h>
main() {
float f;
f = 3/2;
printf ("f = %f\n", f);
}
bor@itsrm2% cc foo.c
bor@itsrm2% ./a.out
f = 1.000000
> I've not seen a way in zsh to modify this to be 'sensible' for humans,
If you can suggest how to 'sensibly' incorporate it into zsh grammar ...
>
> Personally, I'd use the OS's printf(1) if it exists,
It is included into 4.1 branch. I do not know what people think about
adding it into 4.0.3.
-andrej
Messages sorted by:
Reverse Date,
Date,
Thread,
Author