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

RE: question about float variables



> float var1=0.0
> var1=$((3 / 2))
> echo $var1
> 
> return 1.000000000e+00 not good ! :(
>


bor@itsrm2% float var1
bor@itsrm2% var1=$((3.0/2))
bor@itsrm2% print $var1
1.500000000e+00

Integer divided by integer is integer.

> and how to format the output of $var1 ?
> (i want a number like 95.3)
>

Should I just say RTFM?

typeset description:

    -E
          Use an internal double-precision floating point
          representation.  On output the variable will be converted to
          scientific notation.  If N is nonzero it defines the number
          of significant figures to display; the default is ten.

    -F
          Use an internal double-precision floating point
          representation.  On output the variable will be converted to
          fixed-point decimal notation.  If N is nonzero it defines the
          number of digits to display after the decimal point; the
          default is ten.


-andrej



Messages sorted by: Reverse Date, Date, Thread, Author