Division of random numbers, see if the result is an integer.

Simple and yet cant find an easy way around it.
I have 2 RANDOM numbers coming in, I'm dividing them and I want to see if the result is an integer or not. Basically I need to see if the divison of the 2 random numbers provides a whole number.
Who wants KUDOS?
/spaw
Solved!
Go to Solution.

Use Quotient and Remainder, check if Remainder is 0.

Similar Messages

  • Division of packed numbers giving 0 as result .

    I have a requirement where i need to divide a workarea element of type CURR with that of DATA Type DEC
    My problem is that it is returning result as 0 on division, Point to be noted is that the report has its fixed point arithmetic checkbox as unchecked in Program attribute (it is a SAP Standard Report). I have also tried with field symbols taking type as packed but still the result is 0.
    TABLES : ZFI_CurrencyConv.
    Data: l_data2 type zdec,    "i.e. 9 length and 5 decimal places
              l_data1   type zdec.
    SELECT  Single * FROM zfi_currencyconv
               WHERE company_code = reguh-zbukr
               AND date_from LE reguh-laufd
               AND date_to GE reguh-laufd.
      IF sy-subrc = 0.
            l_data1  =  REGUH-RBETR        "CURR length 12 & 2 decimal places
          l_data2   = ZFI_CurrencyConv-FIXED_EXCHG_RATE
         l_data2 = l_data1 / l_data2.
           REGUH-RBETR = l_data2 .
      ENDIF.
    Here ZFI_CurrencyConv-FIXED_EXCHG_RATE is of type Zdec only  (9 length and 5 decimal places)
           RGUH-RBETR  is of type CURR length 12 decimal 2 places.
    Edited by: Gaurav Deep on Nov 6, 2008 12:09 PM

    Hi,
    I don't know why it gave you 0.5 check the below code it will give you 50.
    DATA: menge LIKE ekpo-menge,
          netwr LIKE ekpo-netwr,
          amnt LIKE ekpo-netwr.
    menge = 10.
    netwr = 500.
    amnt = netwr / menge.
    WRITE amnt.
    if you are using this in bapi pricing conditions then have to adjust it accordingly
    Regards
    Ahsan

  • How to use TextField to add two numbers and show the result.

    hi everybody
    i would like to use JTextField to get addtion of two Numbers,
    for example i am trying to type any integer numbers in JTextField like 7
    and press JButton, called( +) to add anthor number like 7 and press JButton called(=) to get addtion fo
    7 + 7 = 14, at same JTextField.
    so there will be two buttons, one for (+),other for (=).
    i have implement ActionListener in (+) button ,to get Text from JTextField (with getText() method),
    now how do i use same getText() method to get the next number that i will add it with previous number in
    (+) button and get the result whenever i press (=).
    1-type integer number like (4) in TextField.
    2-press addition button(+) to get text by using getText() method and clear TextField.
    3-type anthor integer number like(6).
    4-press (=) button to get the number (6) by using getText() method, calculate 4 + 6 and show the result at same TextField (10).
    i hope it is so clear
    thank u in advance for any advice and suggestion.

    Use your first button to
    String x = JTField.getText();
    int y = Integer.parseInt(x);
    this will get your first value on your + button. Make sure you initialise the int beforehand incase nothing is put in (ie error prevention) then clear the JTField prob using setText(""). Repeat the process for the = button using different variables and add them normally and output the result.
    If your putting more than 1 arithmetic button on the GUI then you'll need to distinguish between them!!!

  • I need help with this program ( Calculating Pi using random numbers)

    hi
    please understand that I am not trying to ask anymore to do this hw for me. I am new to java and working on the assignment. below is the specification of this program:
    Calculate PI using Random Numbers
    In geometry the ratio of the circumference of a circle to its diameter is known as �. The value of � can be estimated from an infinite series of the form:
    � / 4 = 1 - (1/3) + (1/5) - (1/7) + (1/9) - (1/11) + ...
    There is another novel approach to calculate �. Imagine that you have a dart board that is 2 units square. It inscribes a circle of unit radius. The center of the circle coincides with the center of the square. Now imagine that you throw darts at that dart board randomly. Then the ratio of the number of darts that fall within the circle to the total number of darts thrown is the same as the ratio of the area of the circle to the area of the square dart board. The area of a circle with unit radius is just � square unit. The area of the dart board is 4 square units. The ratio of the area of the circle to the area of the square is � / 4.
    To simuluate the throwing of darts we will use a random number generator. The Math class has a random() method that can be used. This method returns random numbers between 0.0 (inclusive) to 1.0 (exclusive). There is an even better random number generator that is provided the Random class. We will first create a Random object called randomGen. This random number generator needs a seed to get started. We will read the time from the System clock and use that as our seed.
    Random randomGen = new Random ( System.currentTimeMillis() );
    Imagine that the square dart board has a coordinate system attached to it. The upper right corner has coordinates ( 1.0, 1.0) and the lower left corner has coordinates ( -1.0, -1.0 ). It has sides that are 2 units long and its center (as well as the center of the inscribed circle) is at the origin.
    A random point inside the dart board can be specified by its x and y coordinates. These values are generated using the random number generator. There is a method nextDouble() that will return a double between 0.0 (inclusive) and 1.0 (exclusive). But we need random numbers between -1.0 and +1.0. The way we achieve that is:
    double xPos = (randomGen.nextDouble()) * 2 - 1.0;
    double yPos = (randomGen.nextDouble()) * 2 - 1.0;
    To determine if a point is inside the circle its distance from the center of the circle must be less than the radius of the circle. The distance of a point with coordinates ( xPos, yPos ) from the center is Math.sqrt ( xPos * xPos + yPos * yPos ). The radius of the circle is 1 unit.
    The class that you will be writing will be called CalculatePI. It will have the following structure:
    import java.util.*;
    public class CalculatePI
    public static boolean isInside ( double xPos, double yPos )
    public static double computePI ( int numThrows )
    public static void main ( String[] args )
    In your method main() you want to experiment and see if the accuracy of PI increases with the number of throws on the dartboard. You will compare your result with the value given by Math.PI. The quantity Difference in the output is your calculated value of PI minus Math.PI. Use the following number of throws to run your experiment - 100, 1000, 10,000, and 100,000. You will call the method computePI() with these numbers as input parameters. Your output will be of the following form:
    Computation of PI using Random Numbers
    Number of throws = 100, Computed PI = ..., Difference = ...
    Number of throws = 1000, Computed PI = ..., Difference = ...
    Number of throws = 10000, Computed PI = ..., Difference = ...
    Number of throws = 100000, Computed PI = ..., Difference = ...
    * Difference = Computed PI - Math.PI
    In the method computePI() you will simulate the throw of a dart by generating random numbers for the x and y coordinates. You will call the method isInside() to determine if the point is inside the circle or not. This you will do as many times as specified by the number of throws. You will keep a count of the number of times a dart landed inside the circle. That figure divided by the total number of throws is the ratio � / 4. The method computePI() will return the computed value of PI.
    and below is what i have so far:
    import java.util.*;
    public class CalculatePI
      public static boolean isInside ( double xPos, double yPos )
         double distance = Math.sqrt( xPos * xPos + yPos * yPos );        
      public static double computePI ( int numThrows )
        Random randomGen = new Random ( System.currentTimeMillis() );
        double xPos = (randomGen.nextDouble()) * 2 - 1.0;
        double yPos = (randomGen.nextDouble()) * 2 - 1.0;
        int hits = 0;
        int darts = 0;
        int i = 0;
        int areaSquare = 4 ;
        while (i <= numThrows)
            if (distance< 1)
                hits = hits + 1;
            if (distance <= areaSquare)
                darts = darts + 1;
            double PI = 4 * ( hits / darts );       
            i = i+1;
      public static void main ( String[] args )
        Scanner sc = new Scanner (System.in);
        System.out.print ("Enter number of throws:");
        int numThrows = sc.nextInt();
        double Difference = PI - Math.PI;
        System.out.println ("Number of throws = " + numThrows + ", Computed PI = " + PI + ", Difference = " + difference );       
    }when I tried to compile it says "cannot find variable 'distance' " in the while loop. but i thought i already declare that variable in the above method. Please give me some ideas to solve this problem and please check my program to see if there is any other mistakes.
    Thanks a lot.

    You've declared a local variable, distance, in the method isInside(). The scope of this variable is limited to the method in which it is declared. There is no declaration for distance in computePI() and that is why the compiler gives you an error.
    I won't check your entire program but I did notice that isInside() is declared to be a boolean method but doesn't return anything, let alone a boolean value. In fact, it doesn't even compute a boolean value.

  • Polymorphism and Random Numbers

    Im having issues correctly using random numbers in this program.All I want to do is: generate 4 random ints,and 3 random operators,then prints the results in a toString() method
    import java.util.Random;
    public class TestArithmetic2 {
        // evaluate (int / int) - (int * int)) = result
          //((8.0 / 8.0) - (2.0 * 5.0)) = -10.0
        public static void main(String[] args) {
            Node n = new RandomOps(
                new RandomOps(
                new RandomConst(), new RandomConst()),
                new RandomOps(new RandomConst(), new RandomConst()));
                   public Character RandomOperator(){
                        Random random = new Random();
                        //char array with characters
                        char[] chars = new char[]{'+','-','*','/'};
                        //Generate a random number
                        int r = randomChar.nextInt(chars.length);
                        //Get char at random index
                        char randomOps = chars[r];
                   public int RandomConstant(){
                        int randomConst = 1 + (int)(Math.random() * 20);
                   public String toString(){
                        return "(" + "(" + lChild.eval() + "-" + rChild.eval() + ")" + ")" + "=" n.eval();
            System.out.println(""+ n.eval());
    }

    Opps.Sorry.Here's everything that should help it compile.
    public class Node {
        public Node() {}
        public double eval() {
            System.out.println("Error: eval Node");
            return 0;
    import java.util.Random;
    public class TestArithmetic2 {
        // evaluate (int / int) - (int * int)) = result
          //((8.0 / 8.0) - (2.0 * 5.0)) = -10.0
        public static void main(String[] args) {
            Node n = new RandomOps(
                new RandomOps(
                new RandomConst(), new RandomConst()),
                new RandomOps(new RandomConst(), new RandomConst()));
                   public Character RandomOperator(){
                        Random random = new Random();
                        //char array with characters
                        char[] chars = new char[]{'+','-','*','/'};
                        //Generate a random number
                        int r = randomChar.nextInt(chars.length);
                        //Get char at random index
                        char randomOps = chars[r];
                   public int RandomConstant(){
                        int randomConst = 1 + (int)(Math.random() * 20);
                   public String toString(){
                        return "(" + "(" + lChild.eval() + "-" + rChild.eval() + ")" + ")" + "=" n.eval();
            System.out.println(""+ n.eval());
    public class Binop extends Node {
        protected Node lChild, rChild;
        public Binop(Node l, Node r) {
             lChild = l; rChild = r;
    }

  • How can I fix the crop? When I crop my photos and click okay, the layer no longer shows the resulting photo -- just a dark gray background.

    Can anyone help me to resolve my cropping issue? I have either hit a key I wasn't supposed to hit accidentally, or the software needs to be fixed or reset.  And if I reset or reinstall the software (Photoshop Elements 10 + Organizer), will all my categorized photos in the Organizer be lost with the new installation?
    I have three screen shots to help show my problem.
    The first one is the page before I make any cropping edits:
    This next one shows the beginning of making the crop, before clicking the green check mark to accept the crop. Notice the photos are still intact and visible in the layers:
    And when I accept the crop (by clicking the green checkmark), below is the view of my resulting new layers (the photo is no longer there):
    As you know, what I should see is the resulting, cropped photo in both layers -- not a grayed-out set of boxes.
    How can I fix this to get the crop feature to work again?
    Thanks in advance for your help!
    Gordi

    Click this little triangle and choose Reset Tool from the popout menu:

  • How to hide the all rows except the result row in a report?

    Hi Experts,
    We have a report in which the user is interested to see only the result rows and I need to HIDE the characteristics in the rows. I was successfull in doing the same for Key figures in columns using "Calculate single value as suppress result". But I am not finding a way out to hide the characteristics in the rows.
    If I move the characteristics in rows to Free characteristics, the result row is not getting dispalyed. Also, the characteristics are  used dynamically by the formulae in columns and hence i cant remove these characteristics from the query. . The user wants the query to contain only one characteristic in the row and the result row for the key figures in columns. The report currently displays Invoice level data for each customer and this needs to be eliminated and it should display the summarised  data for every customer. Please suggest how this can be accomplished
    Regards,
    Kavitha

    Moving the char to free char will show the equivalent of result.
    Your issue likely is that this breaks the calculations since you do want the calculations done at detail level.
    To achieve this, move your char to free char (say it is 0CUSTOMER).
    For the CKF/Formula, go to aggregation tab, set the exception aggregation as Total (or whatever it was in standard behavior) and specify reference characteristic (in this case 0CUSTOMER), also check the 'Before aggregation' if you have that checkbox there.
    This will ensure the calculation is done at detail level even though the char is not included in the rows.
    If you have multiple chars to be moved to free char but included in detailed calculation, you will need to build cascading CKFs (CKF1 with ref char1, CKF2 eq to CKF1 with exception aggr on ref char2...and so on).
    Added:
    I understand you do want 0CUSTOMER in there, but something else (let us say 0DOCNO) removed. Use 0DOCNO in place of 0CUSTOMER in the case described above.
    Edited by: Ajay Das on Aug 5, 2009 8:57 AM

  • Action Playback option changes the Result of an Automated Script.

    When using the Playback Option in the Actions menu, then the  Results are different with different Acceleration methods.
    So the Result is different with, Accelerated - Step by Step - Pauze for [1],
    I Expierence the issue with Windows and Mac as well.
    This happens with Illustrator CS5 (15.0.1)
    # Workflow
         Creating the action:
         Open Illustrator, open the attached document: 4102107 Exact.pdf
         Create an New Action, enable Transform window
         Select the Black Square and the Red text Exact
         Go to Object, Scale > 33.3% and press Copy.
         Then go to Transform an from the upper corner and enter on the
         x=397,13 pt y=212,25 pt
         You see the Image moved to the correct clip.
         Open the Document in Illustrator,
         Go to Actions > Select the created action >Now go to the Panel Menu from Actions > Select Playback option.
         You get a new Dialog where you can select a different acceleration mode: "Step by Step" - "Accelrated" - "Pause for [Numeric] Seconds"
         So the issue is, when you select here a different accelration the result is different.
    >Is this as Designed? If So, why because when i understand the function of an automated script. It should exactly get the same
    result as programmed, why else would you want to use the script if the result with be different without nothing.
    There is running an Escalation case about this, But hopefully anybody more experienced can comment me about this. Or inform wheter  it's a bug?
    Please help me in this. (thank you in advance!)

    To make a few things clear I have created a Video of the issue.
    Have a look on:
    http://adobesupport.emea.acrobat.com/p65456795/
    Maybe i really blow in explaining what exactly happens, but i'll try it again.
    When creating an action (as shown in the Video) You can see that the result
    is totally different and when creating the action. This is error 1.
    - I recieved a respons that we just shouldn't use the Transform Panel. So i requested to know why there is a panel created, if we cannot use it.
    No respons.
    Then when you select a Playback option in the setting of the Actions Panel,
    the Result differs. As you can see when executig in the Accelerated the Movement gets placed WAY out of the file.
    When selection Step by Step or Pause for [Numeric] Seconds, then the result is that the movement gets placed
    at the bottom of the file. Both of the Results don't even come close in the Action which is created.
    Hopefully this will calrify what i ment.

  • Bips and random numbers while making calls

    When talking on the phone (iPhone 4 with iOS 6) I get beeping noises and random numbers generated at the top of the screen. Has anyone else encountered this? HELP!

    I'm having the same issue and it has just started after the recent OS update. I have a 5S. Hope there is a fix, as it is terribly annoying.

  • Unique Random numbers

    How to get unique random numbers every time in AS3
    I have searched but not able to get satisfactory results

    var rand :Number;
    rand = Number(movXml.movie.length());
    for(var n:uint = 0 ; n<5 ; n++)
    num1 = Number(Math.round(Math.random()* ((rand-1) - 0) + 0 ) );
    if(tempArray.indexOf(num1) == -1)
    tempArray.push(num1);
    //trace(tempArray);
    num2  = Number (tempArray[0]);
    //trace("num1:"+num2);
    trace(tempArray);
    some time this produce more than 5 numbers
    and some time less than 3
    I want 4 random numbers , but different
    the above loop runs 4 times , so if number is repeated , it will not add to Array , hence i will not able to get 4 Required numbers

  • In my numbers when I click on a cell it shows the formula but what I want ot see is the number I input inot the cell.  what did I do and how can I change it?

    In Numbers, when I click on a cell I see the formula, how do I see the number I input inot the cell?

    Gerald,
    A cell either contains:
    1) what you typed (or entered) OR
    2) the result of a formula
    to enter a formula, select a cell, then type the "=" sign then the formula, then enter
    to enter a number oer text, then type the number(s) or text you want, then the enter key
    the contents of a cell is the last thing you typed into that cell.  If there was a formula, then selecting the cell and typing will result in losing the formula.
    B3 will change as you modify the cell contents in B1 and B2

  • Generate the random numbers

    How Do I Generate Random Numbers in iWorks
    Excel has the "F9" key to generate random numbers numbers don't
    please see below what i'm trying to do
    I open up a blank Excel worksheet, and type the number "1" into cell A1. Type the number "2" into cell A2. Then type the number "3" into cell A3. Type the number "4" into cell A4, and then type the number "5" into cell A5.
    2
    Type the word "PB" into cell A6.
    3
    Enter the function "=RANDBETWEEN(1,59)" into cell B1.
    4
    Enter an exact copy of this function "=RANDBETWEEN(1,59)" into cells B2, B3, B4, and B5.
    5
    Enter the function "=RANDBETWEEN(1,39)" into cell B6.
    6
    Hit the "F9" key to generate the random numbers simulating game.
    But in numbers how do i do this?
    Thanks!
    Alex...

    firstly your not asking about generating random numbers, your asking how do you make a workbook recalculate new random numbers. From M$'s website:
    F9
    Calculates all worksheets in all open workbooks
    It does not produce random numbers the equations should produce random numbers as soon as you enter them in. If they dont then you have automatic reclaculations turned off and F9 is forcing a recalc.
    In numbers there is not shortcut to forcing the workbook to recalculate other than enter data into a cell. So if you made a new table and then enter data. For every data point you enter you should see new data apear.
    Was just validating the method for forcing and its not working on my ipad. I will mark this conversation and if i find it i will respond again.
    Jason
    Message was edited by: jaxjason

  • I use Yahoo Calendar on my IPhone.  For whatever reason when I go into my calendar I will see at the top of the screen that 5 or 6 "calendars" are being used and one of them is the one I called Dana_Gardner and is legitimate, the others are randomly named

    I use Yahoo Calendar on my IPhone.  For whatever reason when I go into my calendar I will see at the top of the screen that 5 or 6 "calendars" are being used and one of them is the one I called Dana_Gardner and is legitimate, the others are randomly named with letters and numbers. Why is the IPhone creating additional "calendars"? I only asked for one to be set-up. I don't understand, I have to go into the calendar settings daily and uncheck these un-asked for calendars. Help!

    Mine is doing the same thing.  I deleted the whole account from the mail settings and it got rid of most of the extra calendars.  But there are still 2 gibberish ones left.

  • Not able to see the result in particular column of BPC report

    Dear All,
    I have problem in one of the BPC report where I am not able to see the result into one column but rest of the users are able to see the result for same column in same report without any issues.
    Generally, I used this report frequently but having such problem from last few days. Excel has created any logs which I need to clear? Please advice.
    Request your help to resolve such problem please.
    If you need any information, please let me know.
    Thank You
    Kind Regards
    Anukul

    Hello Anukul,
    In the report what type of data you are trying to check in that column. can you please brief about report.
    And also please check the excel cell format (right click and check it is a numeric or character), which may help to resolve this issue.
    Regards,
    Rajesh.K

  • I am trying to generate an array of 30 random numbers. after every 5 readings a new vi should open and tell the user that 5 readings has been completed. and again carry on with the generation of array.

    since i do not have a transducer now, i am currently generating an array of 30 random numbers. after every 5 readings a warning should be given to the user that 5 readngs are complete. this cycle should repeat. the array size is 30.
    please help me out,  waiting for reply asap.
    once i have the transducer, i will be taking 30 analog samples and then after every 5 smaples that wraning will be displaye din a new VI
    Solved!
    Go to Solution.

    Use a while loop with a time delay representing your sampling period.
    Use the count terminal to check if equals 4, so 4th iteration=5th sample.
    Use a case structure. The true case will only be executed on the 4th iteration.
    In the true case place a subVI  with your desired message in the front panel. Go to the VI properties window and set "open front panel when called".
    The closing condition of the warnign is not giving in your description.
    Consider that rather than usign a subvi for this, you could use the "One/Two/Three button dialog" or "display message" vis at the "dialog and user interface" pallete.
    Please give it a try and send your own VI. Do not expect us to provide a working solution.
    Regards,

Maybe you are looking for