954,529 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Random number (not ordinary)

Hi again,
With silly question...
I read about generating random numbers
random(10); but it gives numbers from 0 to 10 and i need for example from 10 to 100.

I tried random([10..100]); but i can't compile this :/
Could somebody help me?

evaldaskowka
Newbie Poster
10 posts since May 2011
Reputation Points: 10
Solved Threads: 0
 

low+random(maximum-low+1)

So

10 + random(100-10+1)

random(10) gives values until 9.

pyTony
pyMod
Moderator
5,359 posts since Apr 2010
Reputation Points: 782
Solved Threads: 852
 
uses
  Math;
....
var
  d: integer;
begin
  d :=  RandomRange(10,100);
end;
Wolfgan
Junior Poster
101 posts since Jun 2010
Reputation Points: 34
Solved Threads: 14
 

thanks tonyjv, your code worked :)

But another problem ocurred, i haven't thought that random will give me numbers like 11,12,13 etc haha
Im using 20,40,60 etc numbers so yeah tryin to solve this, can someone still help me?

evaldaskowka
Newbie Poster
10 posts since May 2011
Reputation Points: 10
Solved Threads: 0
 

trunc(my_random_number/10)*10

pyTony
pyMod
Moderator
5,359 posts since Apr 2010
Reputation Points: 782
Solved Threads: 852
 

I do not understand why you need random numbers. 12,13,14 - this sequence.

Wolfgan
Junior Poster
101 posts since Jun 2010
Reputation Points: 34
Solved Threads: 14
 

read my post i dont need these numbers i only need 20,40,60 etc numbers because my program runs on 20x20 rectangles :)

evaldaskowka
Newbie Poster
10 posts since May 2011
Reputation Points: 10
Solved Threads: 0
 

What is the difficulty. You have already prompted all that is required. Think beyond yourself. This is an elementary task.

Wolfgan
Junior Poster
101 posts since Jun 2010
Reputation Points: 34
Solved Threads: 14
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: