Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

RE: question about float variables



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