Dividing numbers > 65***


Closed Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2007
    Posts
    30

    Default Dividing numbers > 65***

    Hi all!

    I've got this code:

    Code:
    W1 = (W0 * 100) / (I / 1000)
    let's suppose that I is 10000 and W0 is 900 we have this:

    Code:
    W1 = (900 * 100) / (10000 / 1000)
    now 900 * 100 is executed and return a 32 bit number: 90000
    10000/1000 is executed and return an 8 bit number: 10

    as you can see, the result 90000/10 is obviously a 16bit number, but PBP will return the right number or i have to use DIV32?

    and if i have to use DIV32, it can be done this way?:

    Code:
    W1 = (W0 * 100) DIV32 (I / 1000)
    thank you!

    Luca

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by oslinux View Post
    Hi all!

    I've got this code:

    Code:
    W1 = (W0 * 100) / (I / 1000)
    let's suppose that I is 10000 and W0 is 900 we have this:

    Code:
    W1 = (900 * 100) / (10000 / 1000)
    now 900 * 100 is executed and return a 32 bit number: 90000
    10000/1000 is executed and return an 8 bit number: 10

    as you can see, the result 90000/10 is obviously a 16bit number, but PBP will return the right number or i have to use DIV32?

    and if i have to use DIV32, it can be done this way?:

    Code:
    W1 = (W0 * 100) DIV32 (I / 1000)
    thank you!

    Luca
    DIV32 isn't used that way. It's all in the PBP manual, pages 34-36.

Similar Threads

  1. Replies: 4
    Last Post: - 15th April 2009, 01:54
  2. Multiple if then optimization
    By Mugelpower in forum mel PIC BASIC Pro
    Replies: 35
    Last Post: - 5th March 2008, 12:15
  3. Working with 3 byte numbers
    By Josuetas in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 26th July 2007, 22:59
  4. Splitting numbers and recombining them(EEPROM Error)
    By selbstdual in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 3rd June 2007, 06:40
  5. Math for numbers > 65535?
    By Scottacus in forum General
    Replies: 4
    Last Post: - 30th December 2003, 13:21

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts