Re: Random number generator -- OS X different
Re: Random number generator -- OS X different
- Subject: Re: Random number generator -- OS X different
- From: Daniel Robinson <email@hidden>
- Date: Tue, 24 Apr 2001 22:01:45 -0400
Richard et al,
>
At least you aren't using round!
hehehe
No, but OS X did and therein lies the rub.
--Dan
------------------------------------------------------------------------
Richard 23 wrote:
>
>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
>
_______________________________________________
>
applescript-users mailing list
>
email@hidden
>
http://www.lists.apple.com/mailman/listinfo/applescript-users