Re: real comparison problems [Re: ASTest redux]
Re: real comparison problems [Re: ASTest redux]
- Subject: Re: real comparison problems [Re: ASTest redux]
- From: bill fancher <email@hidden>
- Date: Sat, 28 Sep 2002 07:36:02 -0700
On Saturday, September 28, 2002, at 03:41 AM, has wrote:
John W Baxter wrote:
Oh, and if anyone has any ideas what I might do to compensate for
AS's
stupid treatment of reals, eg:
0.7 * 0.7 = 0.49
--> false
The way to avoid that particular aspect of the nature of binary
floating
point is not to compare floating point values for equality. Decide
how
much of a difference is appropriate to the task at hand to indicate
"not
equal", and compare that for greater than the absolute value of the
difference of the two values.
Hi, yeah. However, I think that's supposed to be AS's job. The problem
with
the above example is that _it's_ the one saying "0.7*0.7-->0.49", but
then
declares it _not_equal_ when comparing that value to a literal 0.49.
It'd
be different if "0.7*0.7" visibly returned "0.489999999999" - your
solution
would work there - but it doesn't.
Any time you display anything less than full precision, you get
"misleading" displays of the sort you mention. But even if you display
full precision, or don't display floating point representations at all,
that doesn't make the fundamental rounding problem go away, or prevent
"puzzling" displays:
0.7 * 0.7 = 0.49
--> false
I think what I'm really looking for is somebody to say "there is no
easy
way to solve this problem as the fault is AppleScript's", so I can
avoid
the issue myself and just warn the user to be aware of this flaw in AS
and
leave them to deal with it themselves. Put me out my misery. :(
Why blame AppleScript? Couldn't you settle for "there is no easy way to
solve this problem, as it's a consequence of binary floating point
representation."? Then you can warn users to be aware of this "flaw" in
AS and every other piece of software. That leaves them to deal with it
themselves. but you leave them better prepared to do so in a broader
context than just AS. Does that put you out of your misery? (That
didn't come out sounding quite right.)
--
bill
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.