When variable may not fits into WORD limitations


Closed Thread
Results 1 to 5 of 5

Hybrid View

  1. #1
    Join Date
    Feb 2013
    Posts
    1,124

    Default When variable may not fits into WORD limitations

    Hello.

    I have a situation when a equation like (a*b*c*d)/(a+b+c+d) to be solved. Variables may change from 1 to 100), so result may be well out of allowed range. How to workaround such situation?

  2. #2
    Join Date
    Sep 2009
    Posts
    755


    Did you find this post helpful? Yes | No

    Default Re: When variable may not fits into WORD limitations

    Result=(a*b)/(a+b+c+d)
    Result=Result*c*d

  3. #3
    Join Date
    Feb 2013
    Posts
    1,124


    Did you find this post helpful? Yes | No

    Default Re: When variable may not fits into WORD limitations

    And another question. I need to have X divided by 3.6 , since we don't have fractions, I can do X*10/36. But, X*10>65536, so this also does not works. The partial workaround is X*5/18. But still, won't work for large X values. Any ideas how to do conversion?

  4. #4
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Default Re: When variable may not fits into WORD limitations

    I have a situation when a equation like (a*b*c*d)/(a+b+c+d) to be solved. Variables may change from 1 to 100)
    IF your numbers are <= 100 ... a*b*c*d maximum value is ???

    that is outside or inside the compiler limitations ???

    just my two cents ...

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  5. #5
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,607


    Did you find this post helpful? Yes | No

    Default Re: When variable may not fits into WORD limitations

    I need to have X divided by 3.6
    As with most things it depends....on the resolution and accuracy you need and/or can live with it. Try X */ 71 or X ** 18204 or use DIV32 or switch to a LONG (if using 18 series).

    /Henrik.

Similar Threads

  1. Word variable and storing correct value
    By Scampy in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 28th December 2012, 12:04
  2. How to isolate 10 bits from word variable?
    By rcbandwidth123 in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 14th April 2008, 20:18
  3. adding new word variable ?
    By iugmoh in forum General
    Replies: 4
    Last Post: - 21st February 2008, 00:26
  4. Convert a word variable to decimal
    By Tomexx in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 4th December 2004, 20:02
  5. word variable to 25lc640
    By TONIGALEA in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 6th July 2004, 19:59

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