variable + decimal


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302

    Default variable + decimal

    I have a variable as word
    XL VAR WORD
    LO VAR XL.LOWBYTE
    HI VAR XL.HIGHBYTE
    and a decimal number.
    How can to add the decimal to variable and after to write to eeprom;
    like this : 13000(variable) + 622,784(decimal - is always the same number) = 13622,784
    The decimal 622,784 is from division 38,924/0,0625
    Last edited by savnik; - 18th August 2009 at 13:43.

  2. #2
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    947


    Did you find this post helpful? Yes | No

    Default

    Doing 13000 + 623.4
    is same as doing
    13000*10 + 623.4*10
    =136234

    when you want to recover it, simply divide by 10 to get the result
    =13623.4

    You have to make sure to live within the integer limits of PBP unless you are using the long version PBPL.

  3. #3
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302


    Did you find this post helpful? Yes | No

    Default

    I can live with the integer limits of PBP.
    I can not use PBPL because i use pic16f88.

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


    Did you find this post helpful? Yes | No

    Wink

    Hi, Savnik

    Is your decimal number a constant ??? ... and could you tell us where it comes from.

    as

    The decimal 622,784 is from division 38,924/0,0625
    and ALSO the same as ...

    38,924 * 16 !!!

    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
    Jun 2006
    Location
    Greece
    Posts
    302


    Did you find this post helpful? Yes | No

    Default

    Yes it is a constant number.
    is from : 28,224+10,7 = 38,924 and the 0,0625 is the step
    Last edited by savnik; - 18th August 2009 at 14:39.

Similar Threads

  1. EEPROM Variables (EE_Vars.pbp)
    By Darrel Taylor in forum Code Examples
    Replies: 79
    Last Post: - 26th October 2012, 00:06
  2. Serin #Variable question
    By bluesmoke in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 7th July 2009, 17:48
  3. Help with sound command in 2 programs
    By hyperboarder in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 5th July 2007, 20:36
  4. WORD vs BYTE variable lengths
    By bartman in forum General
    Replies: 0
    Last Post: - 28th November 2005, 21:16
  5. Convert a word variable to decimal
    By Tomexx in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 4th December 2004, 20:02

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