# Generalized formula for producing numbers from Math.random()?

Hassan Naqvi

Ranch Hand

Posts: 158

Dave Vick

Ranch Hand

Posts: 3244

Trevor Green

Ranch Hand

Posts: 44

Hassan Naqvi

Ranch Hand

Posts: 158

posted 14 years ago

Hi Trevor & Dave.

I mean, can we make a generalized formula for generating numbers with our rquired range.Something like this.

(int)(Math.random() * lower limit )+ upper limit..

where lower limit is in my first post is 3 & upper limit is 8.

That is have a generalized formula in which i have to just put lower & upper limts.

Regards,

Hassan.

I mean, can we make a generalized formula for generating numbers with our rquired range.Something like this.

(int)(Math.random() * lower limit )+ upper limit..

where lower limit is in my first post is 3 & upper limit is 8.

That is have a generalized formula in which i have to just put lower & upper limts.

Regards,

Hassan.

Always Belive On Logic!!