• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: (was Int Function) mod bug
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: (was Int Function) mod bug
      • From: Chris Page <email@hidden>
    • Re: (was Int Function) mod bug
      • From: John W Baxter <email@hidden>
    • Re: (was Int Function) mod bug
      • From: Doug McNutt <email@hidden>
  • Prev by Date: Re: Rounding x to y decimal places (was Re: Int Function
  • Next by Date: Re: getting a file list in sorted order
  • Previous by thread: Re: Rounding x to y decimal places (was Re: Int Function
  • Next by thread: Re: (was Int Function) mod bug
  • Index(es):
    • Date
    • Thread