FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Programming Questions & Help
   Syntax
(Moderators: fry, REAS)
   float vs. integer
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: float vs. integer  (Read 261 times)
tom willis
Guest
Email
float vs. integer
« on: May 17th, 2004, 4:12pm »

hi,
i need a function that gives back a random integer number between lets say 20 and 200. but the "random" function only gives back float values. what?s the easiest way to make integer out of float?
 
TomC

WWW
Re: float vs. integer
« Reply #1 on: May 17th, 2004, 4:48pm »

Have a look at the reference for random:
 
Quote:

To convert a floating-point random number to an integer, use the int() function.

-- http://processing.org/reference/random_.html
 
The int reference is here:
http://processing.org/reference/int_.html
 
Hope that helps.
 
c
Guest
Email
Re: float vs. integer
« Reply #2 on: May 17th, 2004, 8:29pm »

hi
 
do this: int yourVariable = int(random(180)+20);
 
c
 
Pages: 1 

« Previous topic | Next topic »