Might be a dumb division question...


Closed Thread
Results 1 to 5 of 5

Hybrid View

  1. #1
    Join Date
    Dec 2005
    Location
    Salt Lake City, Ut, USA
    Posts
    108

    Default Might be a dumb division question...

    Hello all,

    Long time - no post. Hope everyone is well.
    Here goes my dumb question:

    Word1 VAR WORD
    Word2 VAR WORD

    Word1 = 1000000/Word2

    Can I do that, or is there a method I may be missing?

    Thanks all,
    Chris

  2. #2
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default Re: Might be a dumb division question...

    Tray this should work:

    Word1= 1000*1000
    Word1= Div32 Word2

    Word2 cannot be larger then 32768 (2^15)

    Cheers

    Al.
    All progress began with an idea

  3. #3
    Join Date
    Sep 2010
    Location
    Las Vegas, NV
    Posts
    305


    Did you find this post helpful? Yes | No

    Default Re: Might be a dumb division question...

    I don't think so. What if Word2 = 1 your result would be 1000000 which is well beyond 65535 a WORD variable can handle. You'd have to use a PBP LONG and a 18F chip I think.

    Someone else already posted a viable solution.

  4. #4
    Join Date
    Dec 2005
    Location
    Salt Lake City, Ut, USA
    Posts
    108


    Did you find this post helpful? Yes | No

    Default Re: Might be a dumb division question...

    Thanks guys,

    Aratti's math appears like it will do the trick.

    Thanks again,
    Chris

  5. #5
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default Re: Might be a dumb division question...

    I don't think so. What if Word2 = 1 your result would be 1000000 which is well beyond 65535 a WORD variable can handle. You'd have to use a PBP LONG and a 18F chip I think.
    In such a case you con intercept the condition with an "IF / THEN" instruction, so that you can handle the error.

    For instante: If Word2 is less than 16 goto skip. And handle the math in a different way.
    Cheers

    Al.
    Last edited by aratti; - 25th July 2013 at 07:49.
    All progress began with an idea

Similar Threads

  1. Dumb Question/Understanding PBP pieces
    By PickyBiker in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 1st April 2010, 19:10
  2. dumb question
    By osceola in forum General
    Replies: 93
    Last Post: - 26th August 2009, 18:39
  3. really simple, dumb question
    By picster in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 3rd March 2007, 22:02
  4. Dumb question
    By Christopher4187 in forum General
    Replies: 0
    Last Post: - 20th June 2006, 12:02
  5. More IF_THEN dumb questions.
    By ronjodu in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 22nd February 2005, 19:33

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