On Sat, Jan 31, 2009 at 8:33 PM, Robert Rohde <raro...@gmail.com> wrote:
> This discussion is getting side tracked.
>
> The real complaint here is that
>
> {{#expr:(0.00007 * 1000 * 1000) mod 1000}} is giving 69 when it should give 
> 70.
>
> This is NOT a formatting issue, but rather it is bug in the #expr
> parser function, presumably caused by some kind of round-off error.

$ php -r 'echo (0.00007 * 1000 * 1000) % 1000 . "\n";'
69
$ php -r 'echo (int)(0.00007 * 10000000) . "\n";'
699

The issue is bog-standard floating-point error.  If PHP has a decent
library for exact-precision arithmetic, we could probably use that.
Otherwise, template programmers will have to learn how floating-point
numbers work just like all other programmers in the universe.

_______________________________________________
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

Reply via email to