I have a sandbox with hundreds of test numbers to exercise the {delimitnum} template. This template uses the same math-based functions as {val}. For anyone who has produced improved math functions, you can examine values on this sandbox that currently produce rounding errors and test your new math functions. The sandbox is at the following:
http://en.wikipedia.org/wiki/User:Greg_L/Delimitnum_sandbox
At the very bottom of the page (which loads slowly), is a concise list of values that all have errors.
It would still be much better if a character-counting parser function can be made. Then, numbers like {{val|1.4500}} won’t have its two trailing zeros truncated.
Greg L
On Jan 31, 2009, at 8:02 PM, Robert Rohde wrote:
On Sat, Jan 31, 2009 at 5:43 PM, Aryeh Gregor Simetrical+wikilist@gmail.com wrote:
On Sat, Jan 31, 2009 at 8:33 PM, Robert Rohde rarohde@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