# round(rands)

9 messages
Open this post in threaded view
|

## round(rands)

 I can't round a random number.         num1 = rands(2,10,1,6747);         num2 = 9.58674394;         num3 = round(num1);         num4 = round(num2);     echo(num1);     echo(num2);     echo(num3);     echo(num4); this provides: ECHO: [2.422436106950045] ECHO: 9.58674394 ECHO: undef ECHO: 10 I don't see anything wrong with trying to get a random integer with this method. Is this a bug? Chris Thompson, eagleapex.com GPG key available "Obscurity is a far greater threat to authors and creative artists than piracy" -Tim O'Reilly
Open this post in threaded view
|

## Re: round(rands)

 Chris rands returns a vector (list) of random numbers even though you are telling it to return one random number in the list. you need to do: list=rands(2,10,1,6747); num1=list[0]; etc... Regards Giles On 16 July 2012 21:12, Chris Thompson <[hidden email]> wrote: > I can't round a random number. > >         num1 = rands(2,10,1,6747); >         num2 = 9.58674394; >         num3 = round(num1); >         num4 = round(num2); >     echo(num1); >     echo(num2); >     echo(num3); >     echo(num4); > > this provides: > ECHO: [2.422436106950045] > ECHO: 9.58674394 > ECHO: undef > ECHO: 10 > > I don't see anything wrong with trying to get a random integer with > this method. Is this a bug? > > > Chris Thompson, eagleapex.com > GPG key available > "Obscurity is a far greater threat to authors and creative artists > than piracy" -Tim O'Reilly > _______________________________________________ > OpenSCAD mailing list > [hidden email] > http://rocklinux.net/mailman/listinfo/openscad> http://openscad.org - https://flattr.com/thing/121566
Open this post in threaded view
|

## Re: round(rands)

 OK, like an Array?         num1 = rands(2,10,1,6747);         num7 = round(num1[0]);     echo(num1[0]);     echo(num7); provides: ECHO: 2.422436106950045 ECHO: 2 I added a bit of explanation to the User Manual. Thanks! Chris Thompson, eagleapex.com GPG key available "Obscurity is a far greater threat to authors and creative artists than piracy" -Tim O'Reilly On Mon, Jul 16, 2012 at 4:17 PM, Giles Bathgate <[hidden email]> wrote: > Chris > > rands returns a vector (list) of random numbers even though you are > telling it to return one random number in the list. > > you need to do: > > list=rands(2,10,1,6747); > > num1=list[0]; > > etc... > > Regards > > Giles > > On 16 July 2012 21:12, Chris Thompson <[hidden email]> wrote: >> I can't round a random number. >> >>         num1 = rands(2,10,1,6747); >>         num2 = 9.58674394; >>         num3 = round(num1); >>         num4 = round(num2); >>     echo(num1); >>     echo(num2); >>     echo(num3); >>     echo(num4); >> >> this provides: >> ECHO: [2.422436106950045] >> ECHO: 9.58674394 >> ECHO: undef >> ECHO: 10 >> >> I don't see anything wrong with trying to get a random integer with >> this method. Is this a bug? >> >> >> Chris Thompson, eagleapex.com >> GPG key available >> "Obscurity is a far greater threat to authors and creative artists >> than piracy" -Tim O'Reilly >> _______________________________________________ >> OpenSCAD mailing list >> [hidden email] >> http://rocklinux.net/mailman/listinfo/openscad>> http://openscad.org - https://flattr.com/thing/121566> _______________________________________________ > OpenSCAD mailing list > [hidden email] > http://rocklinux.net/mailman/listinfo/openscad> http://openscad.org - https://flattr.com/thing/121566
Open this post in threaded view
|

## Re: round(rands)

Open this post in threaded view
|

## Re: round(rands)

Open this post in threaded view
|

## Re: round(rands)

Open this post in threaded view
|