Results 1 to 6 of 6

Thread: What does data look like in memory?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jul 1999
    Location
    Huntingdon Valley, PA 19006
    Posts
    1,151
    A forum question led me to investigate what Double variables actually look like in memory. I thought I could easily find out by writing some data to a file and using a Hex Editor to look at the records.

    What I saw confused me. Perhaps my hand-calculated Decimal to Hex/Binary conversions were incorrect. Perhaps my Hex Editor is messed up.

    Can anyone describe bit by bit (or byte by byte) what single & double variables look like in actual machine language?

    The Longs & Strings in my file looked like I expected, so my Decimal to Hex conversions for integers was correct.

    Thanx --- Live long & prosper.

  2. #2
    Fanatic Member
    Join Date
    Jan 1999
    Location
    UK
    Posts
    554
    I expect that single and doubles only vary in length
    In that a double may be 32 bit and a single may be 16bit or should that be
    a double is 16 bit and a single is 8bit, so from there, you can take each bit and and add them until you have the desired length and then try to decipher it

    Does that makes sense?

    DocZaf
    {;->

  3. #3
    Hyperactive Member
    Join Date
    Mar 2000
    Posts
    461
    Don't forget that in machine language more often than not the bytes of a number are REVERSED.

    Unlike human beings who read from right to left, the computer reads from left to right.

    So lets say you had the number 1024 which in Hex is 0400

    Looking in memory you would be looking for 0004


  4. #4
    Hyperactive Member
    Join Date
    Nov 1999
    Location
    Galway, Ireland
    Posts
    316

    That A 4 byte Long field is a binary intel format integer, in standard
    intel layout (i.e low byte, high byte, low byte, high byte). So for example
    - a Long of 93 decimal would be stored as:

    0x5D 0x00 0x00 0x00

    Slan

  5. #5
    Addicted Member
    Join Date
    Aug 1999
    Location
    Ottawa,ON,Canada
    Posts
    217
    Also don't forget that a number can also be signed.

    If I can remember from my computer architecture class I think the Intel layout included the mantissa, the power of the mantissa, the sign of the mantissa, and the twos complement of the actual number. Then the number is stored in reverse byte order.

    I might be wrong, but I think this is how it is. I can't be sure without my papers.

  6. #6
    Member
    Join Date
    Feb 2000
    Location
    Toronto, Canada
    Posts
    44


    The lower address contains the least significant byte and the higher address contain the most significant byte.

    Example,

    123456789 (decimal)
    =C95595 (hexadecimal)
    C9 55 95 (seperate into bytes)

    The following variable will be viewed in memory;

    ADDR - Value
    0000 - 95
    0001 - 55
    0002 - C9

    Things get a little different with numbers that contains decimal points. The decimal value is converted using the binary weighted fraction method. Example,

    45.25 (decimal)
    =2D.40 (hexadecimal)

    Note: the decimal point is refered to as the radix point in other number bases.

    But I don't know how the computer would store this value in memory. How does the computer distiguish the hexa value as a whole number or a fraction? Maybe the most significant bit in the most significant byte is reserved to tell the computer what type of number it is????? Just like it does with signed numbers. I'am not sure.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width