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

Re: Floating point modulus - the "why not"



On Mon, 12 Jan 2015 21:38:52 -0800
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> I think we did the right thing, but just as a counter-point:
> 
> torch% print $(( 91 % 13 ))                 
> 0
> torch% print $(( 9.1 % 1.3 ))    
> 1.2999999999999994

That's the same problem with floating point division as everywhere else;
if you need to round it, you need to decide what you're rounding to and
add half of that before you truncate downwards.  I don't think that's a
fundamentally new effect in this one case.

pws



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