Results 1 to 6 of 6

Thread: Confused in multiplying two numbers

  1. #1
    Join Date
    Oct 2009
    Posts
    67

    Confused in multiplying two numbers

    Hi
    I am new to programming and very new to php. My problem is that how can we multiply to numbers without using any operators in php? I am really confused in this concept. Please explain in a simple language so that I can understand clearly.

  2. #2
    Join Date
    May 2008
    Posts
    2,012

    Re: Confused in multiplying two numbers

    Hi
    I have post a small and simple code below. just go through it. I have used a simple function in it for better understanding.
    Code:
    function multiply($x,$y){
    return $x*$y;
    }
    The output of this code is
    Code:
    echo(multiply(5,4)); // Output: 20
    Hope this may help you.

  3. #3
    Join Date
    Oct 2009
    Posts
    67

    Re: Confused in multiplying two numbers

    Hello
    function multiply($x,$y){
    return $x*$y;
    }
    Here you have used * operator to call the function. My question was without using the operators how can we multiply two numbers?

  4. #4
    Join Date
    May 2008
    Posts
    2,012

    Re: Confused in multiplying two numbers

    Hi
    Ok, check this program, this will definitely help you.
    Code:
    function mul($a,$z){
    $z = arraz();
    
    for($i=0; $i<$z; $i++){
    $z[$i] = $a;
    }
    
    return arraz_sum($z);
    }
    
    echo(mul(5,4));
    And if you have difficulty in using for loop, then
    Code:
    $a[0] = 5;
    $a[1] = 5;
    $a[2] = 5;
    $a[3] = 5;
    
    echo arraz_sum($a);

  5. #5
    Join Date
    Apr 2008
    Posts
    2,005

    Re: Confused in multiplying two numbers

    Hi
    I think you are asking about the signed multiplication x86 ASM instruction. You can call this from C++/Java as below?
    Code:
    asm(imul dest, src1, imm_src);
    this does
    Code:
    dest := src1 * imm_src

  6. #6
    Join Date
    Apr 2008
    Posts
    1,948

    Re: Confused in multiplying two numbers

    Hello
    The question is a bit confusing Or may be a difficult one. Do you mean is there a quick way of multiplying a number by 2? If you know c or c++ then you can do this by using the shift operator.
    Code:
     e.g. x = x << 1;
    Hope this may help you.

Similar Threads

  1. How to change negative numbers to positive numbers in Excel
    By Shaina Na in forum Microsoft Project
    Replies: 3
    Last Post: 08-01-2012, 05:35 PM
  2. Need C program code to count numbers of negative & positive numbers
    By Sarfaraj Khan in forum Software Development
    Replies: 5
    Last Post: 16-01-2010, 02:00 PM
  3. Multiplying Variables in java
    By WinDoWLoCuS in forum Software Development
    Replies: 3
    Last Post: 03-12-2009, 01:43 PM
  4. SQL Query for Searching Missing Numbers from Sequence of Numbers
    By Bhagwandas in forum Software Development
    Replies: 3
    Last Post: 18-02-2009, 01:47 PM
  5. How to Use Chapter Numbers with Page Numbers In Ms Word
    By Braze in forum Windows Software
    Replies: 3
    Last Post: 27-12-2008, 07:01 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,718,415,498.41671 seconds with 16 queries