setting values and percentages


Closed Thread
Results 1 to 38 of 38

Hybrid View

  1. #1
    Join Date
    Jun 2009
    Location
    Sc*nthorpe, UK
    Posts
    333


    Did you find this post helpful? Yes | No

    Default Re: setting values and percentages

    Quote Originally Posted by richard View Post
    no its not because of the word var its just the way */ works .

    all of this only applies to pbpw only , pbpl is another story
    Yes */ can only result in a word the same applies to DIV32 in PBP2.xx as LONGs are not supported.

    PBP3 supports LONG variables and */ returns the top 32 bits of a 48 bits internal result, ignoring the lower 16 bits or dividing by 65536 which ever you prefer.

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Default Re: setting values and percentages

    Hi,

    With PBPW a multiplication results in an internal 32bit result. The */ operator returns the middle 16 bits (inherent division by 256) while the ** operator returns the top 16bits (inherent division by 65536) of this 32bit intermediate result. You need a WORD variable to accommodate the "full" result.

    With PBPL a multiplication results in an internal 48bit result. The */ operator returns the middle 32 bits (inherent division by 256) while the ** operator returns the top 32bits (inherent division by 65536) of this 48bit intermediate result. You need a LONG variable to accommodate the full result.

    Yes */ can only result in a word the same applies to DIV32 in PBP2.xx as LONGs are not supported.
    You don't need PBP3 to use LONGs. Support for that was introduced in PBP2.50, 7 years ago. But you DO need to use an 18F part.

    And, finally, DIV32 isn't supported (not needed) with PBPL since it uses a 32bit division routine by default.

    All this according to the manual.

    EDIT: Both the */ and ** operators supports variables on both sides of the operator while DIV32 requires a constant on the right side. You can't do
    Code:
    Dummy = 1000*1000
    Result = DIV32 myVAR   ' Won't work, DIV32 requires division by a constant.
    EDIT again, about that DIV32 requiring a constant.....I'm not sure any more. Must try it on actual hardware so you may want to disregard that for the moment :-)

    /Henrik.
    Last edited by HenrikOlsson; - 4th July 2014 at 10:21.

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


    Did you find this post helpful? Yes | No

    Default Re: setting values and percentages

    Aargh, not allowed to edit my post....
    Regarding the DIV32 - I was wrong, it's more the other way around. Doing Dummy = 1000*1000 won't work because both are constants. At least one of the vaules must be a variable or the compiler will replace the multiplication with a constant resulting in the internal system variables not containing the value for DIV32 to operate on. See here and here for more details.

    Sorry for the mixup in my previous reply.

    /Henrik.

Similar Threads

  1. POT part values
    By Michael in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 24th January 2009, 10:41
  2. Port Values
    By Pesticida in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 2nd January 2007, 20:44
  3. t in POT, c's values
    By selbstdual in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 24th August 2006, 23:30
  4. Numeric Values
    By Armando Herjim in forum General
    Replies: 8
    Last Post: - 28th June 2006, 01:54
  5. Wrong values with COSINE!
    By Eng4444 in forum mel PIC BASIC Pro
    Replies: 24
    Last Post: - 8th May 2006, 16: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