• 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: Random number generator -- OS X different
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Random number generator -- OS X different


  • Subject: Re: Random number generator -- OS X different
  • From: Richard 23 <email@hidden>
  • Date: Tue, 24 Apr 2001 02:54:42 -0700

>It was brought to my attention by Bill Fancher that when run on OS X,
>Script A, posted yesterday, gave skewed results.
>
>After stepping through, I find that the error occurred when OS X rounded
>the results to a an integer. In Script B, adding 0.5 to the result
>solves the problem.

> set ThisNumber to {(the result + 0.05) * 10} as integer

I'm not sure that one should expect much better than "skewed" results
using a single-item list trick to get an integer coercion to work in a
way that I very much doubt it was designed for.

I'm guessing that div, designed to take floating point input returning
and return an integer result would probably be more reliable and
efficient.

set ThisNumber to ((result + 0.05) * 10) div 1

But then I'm probably missing the whole point of this numerical voodoo.

At least you aren't using round!

R23


  • Follow-Ups:
    • Re: Random number generator -- OS X different
      • From: Daniel Robinson <email@hidden>
  • Prev by Date: Re: Reading nested lists from a preference file
  • Next by Date: Simple download question
  • Previous by thread: Re: Random number generator -- OS X different
  • Next by thread: Re: Random number generator -- OS X different
  • Index(es):
    • Date
    • Thread