On Sat, Jan 31, 2009 at 5:43 PM, Aryeh Gregor <simetrical+wikil...@gmail.com> wrote: > 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.
In r46671 I have added an explicit test for floating point numbers that are within 1 part in 10^10 of integers before performing round-off sensitive conversions and comparisons. This should eliminate these errors in many cases. -Robert Rohde _______________________________________________ Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l