• 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: email@hidden (Michael Sullivan)
  • Date: Mon, 19 Aug 2002 19:58:03 -0400
  • Organization: Society for the Incurably Pompous

> email@hidden (Deivy Petrescu) writes:
>
> > 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
>
> I ran into this in PseudoRand, and some other similar code.
> AFAICT, this never produces a bad answer:
>
> set x to 61
> set b to (((x + (2.6 - (2.6 mod 1))) - x) div 1) as integer

Ooops. I mean that *this* never produces a bad answer, unless you're
working close to the limits of FP precision:

set x to 61
set b to (((((x + (2.6 - (2.6 mod 1))) - x) + 5.0E-12) div 1) as
[NO-BREAK]integer)


Michael
_______________________________________________
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.

References: 
 >Re: (was Int Function) mod bug (From: email@hidden (Michael Sullivan))

  • Prev by Date: Re: getting a file list in sorted order
  • Next by Date: "Tell Application" in OS X
  • Previous by thread: Re: (was Int Function) mod bug
  • Next by thread: Re: (was Int Function) mod bug
  • Index(es):
    • Date
    • Thread