Splitting numbers and recombining them(EEPROM Error)


Closed Thread
Results 1 to 3 of 3

Hybrid View

  1. #1
    Join Date
    Aug 2006
    Location
    In a world of german electrons
    Posts
    102

    Default Splitting numbers and recombining them(EEPROM Error)

    Math issue

    I wrote the following numbers to the eeprom
    Position 31 till 40 (included)
    Code:
    2118:  00  00  00  00  00  00  00  03	........ (Position 24 - 31)
    2120:  02  02  06  04  00  03  02  00	........ (Position 32 - 39)
    2128:  01  10  27  64  00  00  00  00	..'d.... (Position 40 - 47)
    Then I wrote the following

    Code:
        READ 31, TenThousand
        READ 32, Thousand
        READ 33, Hundred
        REAd 34, Ten
        READ 35, One
        
        READ 36, BThousand
        READ 37, BHundred
        READ 38, BTen
        READ 39, BOne
        
        Numbers = (TenThousand * 10000) + (Thousand * 1000) + (Hundred * 100) + (Ten * 10) + One
        B = (BThousand * 1000) + (BHundred * 100) + (BTen * 10) + BOne
        
    	WRITE 41, Numbers.Byte0
    	WRITE 42, Numbers.BYte1
    	
    	WRITE 43, B.Byte0
    	WRITE 44, B.Byte1
    Result - as seen in the code above - is for numbers 10 and 27 and for B 64 and 00.

    But being combined and converted to decimal numbers this is not 32264 and 320.

    Why ?
    Last edited by selbstdual; - 3rd June 2007 at 02:33.

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Here's my guess...

    You have all of the variables - TenThousand, Thousand, Hundred etc. declared as BIT instead of BYTE?

    Code:
    DEC             3     2     2     6     4
    BIN          0011  0010  0010  0110  0100
    Bitvar          1     0     0     0     0
    multiplier 10,000 1,000   100    10     1
               ------ -----  ----  ----  ----
               10,000     0     0     0     0
        HEX =    2710h
    
    DEC             0     3     2     0
    BIN          0000  0011  0010  0000
    Bitvar          0     1     0     0
    multiplier  1,000   100    10     1
               ------ -----  ----  ----
                    0   100     0     0
        HEX =    0064h
    DT

  3. #3
    Join Date
    Aug 2006
    Location
    In a world of german electrons
    Posts
    102


    Did you find this post helpful? Yes | No

    Smile Thank you

    Yes, it works after this change.

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