[Newbies] Float comparsion
camillobruni at students.unibe.ch
Fri Feb 27 14:25:54 UTC 2009
hehe thanks for the vivid response ;)
Well then I'll use closeTo, I don't really need a very accurate
But since I want to create a Renderer the performance will be the
problem. Well thats also why I've chosen Squeak ;).
thanks for the responses
Am 27.02.2009 um 13:51 schrieb Bert Freudenberg:
> The Epsilon class variable is used only when the primitives for some
> float functions are not available, in which case they are
> approximated to that precision. Using that same epsilon for
> something else is as meaningless as the 0.0001 in #closeTo:.
> The epsilon really depends on your application.
> - Bert -
> On 27.02.2009, at 13:41, Oscar Nierstrasz wrote:
>> Yes, we looked at that, but closeTo: uses a much larger epsilon
>> than Float's class variable Epsilon.
>> I suggested Camillo wrote an extension method similar to closeTo:
>> but using the existing Epsilon (or an arbitrary one as an
>> additional parameter).
>> Is that the right thing to do?
>> - on
>> On Feb 27, 2009, at 13:34, Lukas Renggli wrote:
>>> Hi Camillo ;-)
>>> Use the method #closeTo: instead of #=. Comparing floats with #=
>>> almost never works.
>>> Although "(Float halfPi / 2) tan" is printed as 1.0, it is not
>>> 1.0 due to rounding errors in the calucaltaion and/or the internal
>>> (Float halfPi / 2) tan - 1.0 --> -1.110223024625156e-16
>>> Lukas Renggli
>>> Beginners mailing list
>>> Beginners at lists.squeakfoundation.org
>> Beginners mailing list
>> Beginners at lists.squeakfoundation.org
> Beginners mailing list
> Beginners at lists.squeakfoundation.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Beginners