swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: thanks & uniformRandom


From: Nelson Minar
Subject: Re: thanks & uniformRandom
Date: Tue, 30 Jan 96 18:08:39 MST

>I want to use uniformRandom to get random floats but do not know the 
>syntax for adding in rFloat into a call to uniformRandom.  None of
>the example apps show it. Does it work like a cast to the object call
>or do I pass it some argument like 'rFloat: YES'.  Can you assist?

I'm not sure what you're asking. Using rFloat on uniformRandom is just
a matter of sending the message to the object.

  float f;
  f = [uniformRandom rFloat];

(btw, anyone know how to correctly generate a random double from
random 32 bit integers? rFloat is easy - floats (usually) have less
than 32 bits of precision, so you just divide the number by the
maximum possible value. But doubles usually have more than 32 bits of
mantissa, so you have to somehow convolve two random integers. libg++
just casts the bits directly into the mantissa of the floating point
number, but that scares me.)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]