word larger numbers


Closed Thread
Results 1 to 7 of 7
  1. #1

    Default word larger numbers

    I have to multiply a byte for the word fixed 10000, and then divide the result by the fixed word 312 (example 73x10000 / 312). How can i do this when the result of the multiplication exceeds the maximum content of a word?

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    2,386


    Did you find this post helpful? Yes | No

    Default Re: word larger numbers

    dummy_word_var = 73*10000
    result_word_var= div32 312


    [result=2339]

  3. #3
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,519


    Did you find this post helpful? Yes | No

    Default Re: word larger numbers

    Or perhaps
    Code:
    73 */ 8205
    Result = 2339

    Or, if precision isn't THAT critical, since 10000/312 = 32.0513 which is pretty close to 32:
    Code:
    73 <<  5
    Result = 2336

    Where obviously the last one will be the smallest and fastes option
    /Henrik.

  4. #4


    Did you find this post helpful? Yes | No

    Default Re: word larger numbers

    Quote Originally Posted by richard View Post
    dummy_word_var = 73*10000
    result_word_var= div32 312
    but 73000 isnt' larger than a word?

  5. #5


    Did you find this post helpful? Yes | No

    Default Re: word larger numbers

    never mind
    Last edited by mark_s; - 16th January 2016 at 18:46.

  6. #6
    Join Date
    Sep 2009
    Posts
    737


    Did you find this post helpful? Yes | No

    Default Re: word larger numbers

    PBP uses internal 32bit register for storing results(registers R1,R2,R3,R4 if I remember correctly). Maximum number that can be stored is 4294967295
    Then DIV32 divide register with 312 in this example.

  7. #7
    Join Date
    Jan 2010
    Location
    PHILADELPHIA, PA - USA
    Posts
    34


    Did you find this post helpful? Yes | No

    Default Re: word larger numbers

    Look into Alexander Avtanski's N-Bit Math which is mentioned in this old post
    http://www.picbasic.co.uk/forum/showthread.php?t=12433
    Wozzy-2010

Similar Threads

  1. how can I caculate with numbers bigger than a word using 16F88 ?
    By Mugelpower in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 17th May 2010, 02:51
  2. Displaying a decimal larger than 255 on LCD?
    By djmachine in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 10th March 2009, 09:02
  3. convert the numbers to word
    By savnik in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 12th April 2007, 08:00
  4. Larger array possible if I move to 18Fxxx?
    By incognico in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 22nd January 2006, 15:03
  5. Array larger than 256 bytes
    By Ron Marcus in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 27th November 2005, 15:38

Members who have read this thread : 1

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