Get a random number between 2 numbers?

Are their any classes which can produce a random number within a set of numbers i specify?
If their are no predefined java classes then it doesnt matter.
Thanks

No as far as I know, but its easy to create one:
double low_Limit, super_Limit;
double interval = super_Limit - low_Limit;
//Generate a random number between 0 and 1, with a Java satandard class
double random_number = Math.random();
//Now we generate a random numbre between 0 and intervalo:
random_number = random_number * intervalo;
// now we generate a random number between low_Limit super_Limit:
random_number = random_number + low_Limit;
//done :)
Abraham.

Similar Messages

  • SsRandom or another way to get a random number

    In iDocScript, I need to get a random number between 0 and 4, or it could be between 1 and 5. I found ssRandom, but am unsure how to use that number to get the range I want. Any other ways or advice?

    I found the answer, below is some iDocScript for generating random numbers.
    [!--$randomIndex = ssRandom()--]
    [!--$if randomIndex lt 0--]
    [!--$randomIndex = randomIndex * (-1)--]
    [!--$endif--]
    [!--$randomIndex = randomIndex % 5--];

  • How I get random number between 1 and int number ?

    how can I get random number between 1 and int number
    like between 1 and 10 etc.
    10x

    Use the nextFloat() method of the Random class, this returns a random number between 0.0 and 1.0. To get and integer range from that multiply the return value of that method call by the integer range you need (in this case 10), and add the starting number you want returned in the range (1 in this case). The code below works for numbers 1-10.
    Random r = new Random();
    int x = (int)(r.nextFloat()*10) +1;

  • How to get a random number in a range?

    as title
    how to get a random number in a range?
    like 2000~3000 thks :)

    int between 10 and 20 with the method Math.random():
    public class Rnd
         // Test
         public static void main(String[] args)
             int start=10, end = 30;
             for (int i = 0; i < 10; i++)
                int n = (int)(start + Math.random() * (end-start));
                System.out.println(n);
    }best regards.

  • Random Number between 10 and 30

    I'm just curious how to generate a random number between 10 and 30. I know I use the Math.Random function, but I'm not certain how to do it when the starting number is >1 (i.e. 1 to 30). Thanks.

    Random Number in an Interval:
    ((int) (randomGeneratedNumber * difference)) + startIndex + 1
    * randomGeneratedNumber - Number >= 0 and <1
    * difference: To generate between 10 and 30, (30 -10 = 20)
    * startIndex: In this example, 10
    * +1: Neccesary adjustment.
    Example:
    ((int)(randomGeneratedNumber * 20)) + 10 + 1
    PD. Int cast it's to generate int numbers, so it's optional.

  • How to Build a VI that generates a random number between 1 and 80 ....Help!!!!

    Build a VI that generates a random number between 1 and 80 
    Divides the random number by a number specified in the front panel.
    If the inputted number is zero, the VI program should turn on a LED in the front-panel to indicate a divide by zero error.
    Solved!
    Go to Solution.

    One quick question Edward, was the answer just in time for your monday morning class.
    Ton
    Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
    Nederlandse LabVIEW user groep www.lvug.nl
    My LabVIEW Ideas
    LabVIEW, programming like it should be!

  • Random number between 1 & 16?

    Hello all.  I need to create a variable that holds a random number  between 1 & 16.  Any idea how I can do this?  This is the way the  variable looks right now:
    var randomTurkey:Number = Math.floor(Math.random()*100);

    Never mind, I got it.  Thanks!

  • How can I find unknown number between specific numbers?

    How can I find unknown number between specific numbers? For example I want to find the start with value from following question... How can I do that? If you run this oracle query SELECT DBMS_METADATA.GET_DDL('SEQUENCE','SEQUENCE_NAME') FROM DUAL to find out my sequence DDL you will see the similar given values that assigned to sequence DDL, and if I can find the result here I will apply same technique to my  C# code to find start with value of sequence in oracle.Thanks –
    Given Values
    Min number=20
    Max Number=500
    increment number=10
    start with=?  needs to be find.
    how many times it increments= 5
    where the cycle stopped now= 205
    Conditions;
    1. Start with number has to be either 20 or 500 or between 20-500...
    2. It always increment 5 times.For example, If the start with number is 75 than numbers goes like First cycle=(75,85,95,105,115) Second cycle=(125,135,145,155,165)...Third cycle (175,185,195,205) and it stops on 205.
    Question is If start with number not known. is there any way to find it?
    Thanks!

    DUPLICATE THREAD!
    Please do NOT keep creating duplicate threads.
    https://forums.oracle.com/thread/2578906
    https://forums.oracle.com/thread/2578830
    Your question has already been answered in your other thread. As I said in your other thread:
    The START WITH value part of the DDL for a sequence is NOT stored in the data dictionary. See the SYS.SEQ$ table for the attributes stored in the dictionary.
    What part of that are you having trouble understanding?
    There IS NO START WITH to find - it does NOT exist!
    Mark this thread ANSWERED and continue using your 2578830 thread if you intend to pursue this further.

  • Random number between a range

    hi all!
    how can i find random number between an specified range
    for example b/w 5-10
    thanks to all
    smh

    Here's a practical instance;-import java.util.Random; // Maybe you forgot this
    public class ImplementRandom {
      public void getRandom(int from, int range) {
         int newRandom;
         Random random = new Random(); 
         newRandom = from + random.nextInt(range);
         System.out.print(newRandom); 
      public static void main(String[] args) {
         ImplementRandom IC = new ImplementRandom();
         IC.getRandom(1, 100);
    }Actually that uses public void rather than public int as you cannot reference a non-static (return-type) method from a static context.

  • Random number between .2 and 1

    How do I generate a random number between 0.2 and 1.0

    ... or for - eg for 2 decimal places try this;-
    java.util.Random rand = new java.util.Random();
    int i = 20 + rand.nextInt(80);
    double d=(double)i;
    d /=100;

  • Random number generation in numbers

    I cannot find out how to create a random number colum. It ios very easy on Excell ,but my attempts on numbers have been frustrating. I look at the instructions, but when I click on formulas it doesnt show the whole list.

    Clark,
    You might find it convenient to have Formulas and Functions Help open as you work on your document. It has a little different layout than the Function Browser.
    Jerry

  • Re: Generating a random number between 1-10;

    How do I generate a number between 1-20? I saw how to on this forum once, but I can't find it, and I don't have much time to look. Sorry for any inconvinience. What I want to do is assign to the variable x the random number.
    Thanks.
    Virum

    Random rnd = new Random();
    int x = rnd.nextInt(20)+1;

  • Generate Random Number in a Numberic Field

    Hello,
    I am wondering if there is a way to Generate a random number in a numeric Field or any other type?
    I am currently using LiveCycle Designer ES 8.2
    thanks,
    -Vargs

    Thanks for the post, I was researching further into what I wanted to do  and found this post
    http://www.acrobatusers.com/forums/aucb … ?pid=60135
    What  I want to do with this random number is generate it every time someone  opens a new form.  This form will be saved on a persons computer and  worked on.  So I don't want the number to change every time the file is  open, only when the form doesn't have a unique number already in it.
    I  believe the answer is the following but I am not sure if it will do the  task I want to perform. Here is the following code
    Quote from  the post by user Jonom:
    "Here's a script I've used on the  Initialize event of a form. It checks to see if it already has a value  and if so doesn't generate a new number in case people save the form and  reopen it:
    The number is unique to the second, so two people  would have to open the form at the same second to get the same value..."
    Code:
    if  (this.rawValue == null) {
        var d = new Date();
        //divide  result by 1000 to get seconds and round off
        this.rawValue =  parseInt(d / 1000);
    else {
        this.rawValue = rawValue;
    end  quote
    How  can I put in this code into a numeric field. I made a numeric field in  Livecycle Designer ES 8.2
    and tried to add in code but was not sure  which event to put it in or where exactly it should be placed.
    Thanks,
    -Vargs

  • How to get a Random number from a list

    Dear Experts,
    I have a list in which I have 24 employee number, and from this I have to select 4 employees number Randomly,
    So please suggest how can I achieve this.
    Warm Regards
    Upendra Agrawal

    Hello
    do 4 times.
    CALL FUNCTION 'QF05_RANDOM_INTEGER'
         EXPORTING RAN_INT_MAX = 24
                   RAN_INT_MIN = 1
         IMPORTING RAN_INT     = ind.
    read table itab index ind.
    " do anything here
    enddo.

  • Random number between a range fix

    Hello
    I need to place an object on the stage.x randomly but not going .
    The stage is 1024 pixel and the object 726. I do the following, it works ok but sometimes some part of the object goes of the stage. Could you tell me what I do wrong?
    menucenter=Stage.width-_root.object._width;
    _root.object._x=Math.floor(Math.random() * (menucenter - 0)) - 0;
    Thank you
    George

    if the object has reg point at it's left edge use:
    _root.object._x=Math.random()*menucenter;

Maybe you are looking for

  • Error while saving Excise Invoice

    Hi,    I am getting an error while saving an excise invoice. It is as follows :     BED :  Debit =  1,400.00  Credit =  392.00  Diff =1,008.00     Message no. 8I312 please help.... Thanks & Regards, S.Rajeswari

  • Unit of measure in Sales Order

    Hi All, We have maintained base unit of measure as EA. the sales unit is not mentioned and hence system will take EA as sales unit also. We have maintained alternate unit of measure as BOX and a conversion factor for the same wrt EA. When user enters

  • Adobe 9 Standard - Converting Excel, diamond-shaped artefacts on some pages...

    I have a user whom I support, using Acrobat 9 Standard, who is having trouble converting some excel documents into .PDF files. She has a number of multi-page, multi-table/chart/graph excel files that she needs to convert to .PDF On most of these file

  • Layoutdelay in different browsers

    hi, i published some day ago our new website http://joergtacke.de on Businesscatalyst. Some browsers make Layoutdelays (Screenshots) Windows & Firefox: https://dl.dropboxusercontent.com/u/88123223/Support/Firefox%20windows.jpg Mac & Chrome: https://d

  • Trying to preorder iPhone 4s. how long at "processing order" page?

    How long should my system be sitting at the Processing page? It has been more than a half hour now.