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

Re: forcing output type



Clint Adams wrote:
>float f; (( f = 2/3 )); print $f
>
>to output the equivalent of what would be output
>if, for instance, the "2" were replaced by "2.0"?

The expression "2/3" is a truncating integer division; its value is
exactly 0.  Just as in C, if you want to do a floating-point division
you have to provide floating-point operands.

-zefram



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