Re: (was Int Function) mod bug
Re: (was Int Function) mod bug
- Subject: Re: (was Int Function) mod bug
- From: has <email@hidden>
- Date: Mon, 19 Aug 2002 14:20:18 +0100
Deivy Petrescu wrote:
>
Here try this:
>
>
set x to 62
>
set b to ((x + (2.6 - (2.6 mod 1))) - x) as integer
>
>
now try this:
>
>
set x to 61
>
set b to ((x + (2.6 - (2.6 mod 1))) - x) as integer
Yeah. Well, you know that amazing, powerful, handsome hunk o' metal and
plastic sitting on your desk there? The one you just paid a couple thousand
bucks for? It can't even add a couple simple numbers together without
getting the answer wrong.2 plus 2 may actually equal 5! (This must be what
they meant by "Think Different.") Can't believe it, huh? Agh!!! What a
piece of junk!
Sad but true: almost any answer you get to a floating point calculation
will be WRONG. (It's an inherent limitation of binary computing.) The only
question you can usefully ask is: "How wrong?" In the end, the system's
designers will probably fudge things a bit, e.g. by rounding a value that's
very, very close to a whole number to that number. Which, 99 times out of
100, will give the result the user was after... and the other time it'll
actually make things worse. (Or, as my old mum would say: "Two wrongs don't
make a right.") And if that's not bad enough, try this thought: the more
you use them, the more wrong they get. Ouch! Head hurting yet? ;p
I sympathise with AS's designers here: just as all floating -point values
are wrong, no language-level solution will be correct. In the end, it may
be that the only option is to educate your users so that they're able to
choose for themselves the most appropriate answer to their own particular
problem.
Hmph. So much for Machines... I'd stick with the grey matter if I were you. ;)
has
--
(My email address has changed from <email@hidden> to
<email@hidden>. Please update your address books accordingly.)
_______________________________________________
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.