On Mon, Feb 25, 2008 at 1:19 PM, fireplace_tea <[EMAIL PROTECTED]> wrote:
> Hi Everyone,
>
>  I'm a little confused on the amount of memory each variable type takes
>  up in RAM.  I understand about bits and bytes and ASCII.  I.E. If you
>  type in DOG each letter is one byte, thus the entire word DOG is three
>  bytes.   If each character is one byte how is it that a long int
>  variable type that can be up to 10 bytes in length only take up 4
>  bytes of memory?

Because the internal representation is only 4 bytes in length, not 10.
 They aren't stored as literal strings. (The decimal representation
will generally be longer however.)

Go back to your first example - the letters D, O and G. D, in ASCII,
is represented by the number 66 in decimal, 0x44 in hex, 0104 in octal
and 0b01000100 in binary. All are 1 byte in length.

I think you need to read up on the (general) internal representation
of integers: http://en.wikipedia.org/wiki/Binary_numeral_system

-- 
PJH

http://shabbleland.myminicity.com/sec

Reply via email to