How can i use random(a,b) but get whole numbers

writing a little program that displaces the coordinates of little circles but it displays them as numbers with many decimals. is there a way to use the random function with ints, or is there a way to display whole numbers

code:

final int DIAM = 5;

String coordinate;

void setup(){ size(500,500); frameRate(1);

}

void draw(){

float randomX = random(80,420); float randomY = random(20,495);

coordinate = "(" + randomX + "," + randomY + ")";

fill(255);

ellipse(randomX,randomY,DIAM,DIAM);

textSize(16); fill(0); text( coordinate,randomX + DIAM,randomY - DIAM);

}

Answers

Sign In or Register to comment.