calculate var Byte's and var Word's


Closed Thread
Results 1 to 6 of 6
  1. #1
    Pedro Pinto's Avatar
    Pedro Pinto Guest

    Default calculate var Byte's and var Word's

    Hello All

    I need to calculate this example:

    varWord = (varByteA*365) + (varByteB*30) + (varByteC/2) + varByteD

    The PIC calculate always varWord = 0

    How can I write this, or must I before calculate copy the var's byte's in word's, like so

    varWordA = varByteA:varWordB = varByteB:varWordC = varByteC:varWordD = varByteD

    varWord = (varWordA*365) + (varWordB*30) + (varWordBC/2) + varWordD



    Thank for any help

    Best Regards

    Pedro

  2. #2
    BertMan's Avatar
    BertMan Guest


    Did you find this post helpful? Yes | No

    Default

    If varByteC is not a multiple of 2, then the result is a floating point, which pbp doesnt support. Also, your word result can be no higher than 65535.
    Last edited by BertMan; - 20th October 2005 at 00:07.

  3. #3
    Pedro Pinto's Avatar
    Pedro Pinto Guest


    Did you find this post helpful? Yes | No

    Default

    Hi,

    what I mean is:

    c var byte
    b var byte
    a var word

    c=12
    b=34

    a=c*b

    Is this correct, or must the var a and b be word var

    Thanks

    Pedro

  4. #4
    Pedro Pinto's Avatar
    Pedro Pinto Guest


    Did you find this post helpful? Yes | No

    Default

    Hi,

    sorry,

    Is this correct, or must the var b and c be word var?

    Regards

    Pedro

  5. #5
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    Only variables whose content is likely to exceed 8 bits need to be WORDS.

    In your example 'a' MUST be a WORD, 'b' and 'c' need not be.

  6. #6
    Pedro Pinto's Avatar
    Pedro Pinto Guest


    Did you find this post helpful? Yes | No

    Default

    Thank You Melany

    Regards

    Pedro

Similar Threads

  1. High Resolution Timer & Speed Calculator
    By WOZZY-2010 in forum Code Examples
    Replies: 4
    Last Post: - 7th February 2010, 16:45
  2. LCD freeze
    By harryweb in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 5th October 2009, 08:01
  3. Changing declared variables names on the fly
    By jessey in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 16th December 2006, 06:34
  4. 16F877 RAM Question
    By Art in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 6th August 2005, 11:47
  5. Problems with variables
    By egberttheone in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 15th December 2004, 18:37

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