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)
   from float to int
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: from float to int  (Read 361 times)
gabon

WWW
from float to int
« on: Sep 6th, 2004, 12:23pm »

I need to calculate randomly the element in an array, how to conver the float received from the random to the int i need to select the item?
 
cheers, chr
 
JohnG

WWW
Re: from float to int
« Reply #1 on: Sep 6th, 2004, 2:53pm »

int x=int(random(array_size));
 
gabon

WWW
Re: from float to int
« Reply #2 on: Sep 7th, 2004, 10:40am »

sorry, i found it... is it from java or a p5 conversion?
 
thx, chr
 
mKoser

WWW Email
Re: from float to int
« Reply #3 on: Sep 12th, 2004, 1:16pm »

the Java way of doing things is:  
int myNum = int(myFloat);
 
the processing way of doing things is:
int myNum = (int)myFloat;
 
both work within processing.
 
+ mikkel
 

mikkel crone koser | www.beyondthree.com | http://processing.beyondthree.com
TomC

WWW
Re: from float to int
« Reply #4 on: Sep 12th, 2004, 3:48pm »

Other way around.  Java uses the C-style (int)whatever, Processing offers a function-style int(whatever) version too.
« Last Edit: Sep 12th, 2004, 4:56pm by TomC »  
mKoser

WWW Email
Re: from float to int
« Reply #5 on: Sep 12th, 2004, 3:54pm »

damn it!
 

mikkel crone koser | www.beyondthree.com | http://processing.beyondthree.com
Pages: 1 

« Previous topic | Next topic »