Math issue, isn't it?

Mick Collins mickclns at mac.com
Sat May 9 03:29:27 EDT 2009


Until the matter is finished being debated and a plan of action is  
decided on, a function could be used such as

function numsAreEqual n1, n2, epsilon
    return abs(n1 - n2) < epsilon
end numsAreEqual

If your testing of the immediate comparison indicates to you that  
there are no roundoff problems, then use =, otherwise use this  
function or your own variant with an epsilon that seems prudent.

> Date: Fri, 8 May 2009 14:49:44 -0700
> From: Bob Sneidar <bobs at twft.com>
> Subject: Re: Math issue, isn't it?
> To: How to use Revolution <use-revolution at lists.runrev.com>
> Message-ID: <67EDCDEC-6D52-4E99-9ABF-A5F03DE3243E at twft.com>
> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes
>
> Yes, but my point was if someone was creating an Accounting
> application, he would have to know to wrap all of his equations in
> value(), otherwise he could not do any logical comparisons on equated
> values. While your approach works, I think that the better approach is
> for this issue to be addressed in a future update. If there is no
> present way to prevent 283.67 - 150 - 133.67 from equaling
> 0.00000000000002842 other than wrapping it in a conversion function,
> then that needs to be addressed. I failed 6th grade math and even I
> know that is wrong! :-)
>
> Bob Sneidar
> IT Manager
> Logos Management
> Calvary Chapel CM
>
> On May 8, 2009, at 2:11 PM, Scott Rossi wrote:
>
>> Recently, Bob Sneidar wrote:
>>
>>> Then the question becomes, should the IDE be doing math on the real
>>> number or the displayed number? I vote for the displayed number
>>> because that means I can have some kind of control over the outcome.
>>> Clearly if some calculation that comes up with a number cannot be
>>> compared to a literal for equal/not equal, then all accounting is  
>>> out
>>> the window. This cannot be an intended behavior!!?!
>>
>> As others have said, the issue arises due to the decimal values -- if
>> integers are used, the comparison works "correctly" (and I'd prefer
>> not to
>> argue over what is "correct").  I don't know if this is an acceptable
>> solution but when I use the value function, I get the expected  
>> result:
>>
>>  put value(283.67 - 150 - 133.67) = 0
>>
>> Regards,
>>
>> Scott Rossi
>> Creative Director
>> Tactile Media, Multimedia & Design
>>
>>
>> _______________________________________________
>> use-revolution mailing list
>> use-revolution at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-revolution
>
>
>




More information about the use-livecode mailing list