|
-
Apr 3rd, 2000, 07:32 AM
#1
Thread Starter
Frenzied Member
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.
-
Apr 3rd, 2000, 07:43 AM
#2
Fanatic Member
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
{;->
-
Apr 3rd, 2000, 07:50 AM
#3
Hyperactive Member
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
-
Apr 3rd, 2000, 08:54 PM
#4
Hyperactive Member
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
-
Apr 3rd, 2000, 09:04 PM
#5
Addicted Member
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.
-
Apr 3rd, 2000, 09:04 PM
#6
Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|