On Sat, Jan 31, 2009 at 10:21 PM, Daniel Friesen dan_the_man@telus.net wrote:
Output a big red error when giving numbers that will encounter a floating point error?
Perhaps also provide a # of use limited #expr equivalent that will use a bignum library rather than normal numbers which can be used in cases where that big red error shows up.
Noticing errors isn't the hard part, but the common user will have a hard time figuring out how to avoid them.
For example:
{{#expr:floor(0.00007*100000)}} = 6 {{#expr:0.07*100 = 7}} is False {{#expr:5/6 = (1/6)*5}} is False {{#expr:(10^16 + 1) % 10}} = 0
All of these are examples of floating point quirks, but at the same time none of them is so complicated that analogous expressions wouldn't come up in practical situations. From the point of view of a non-programmer Mediawiki user, this behavior is both unexpected and cryptic.
The first three are fixable, provided one applies some reasonable tolerance for when two numbers are the same. The fourth would require big math, or failing that should probably generate an error.
-Robert Rohde