内存和地址.

  1. Computer memories are composed of millions of bits, each capable of holding either the value 0 or the value 1. This limited range of values is not terribly useful, so bits are usually grouped together and treated as a unit in order to store a wider range of values.

  2. It is cumbersome to remember all of those addresses, though, so one of the things that high level languages provide is the ability to refer to memory locations by name  rather  than  by  address.

  3. It is important to remember that this association of names with locations is not provided by the hardware, it is something that the compiler does for us. The hardware still accesses memory locations using addresses.

  4. in the following statement an float variable was declared.
    float f = 3.14;    //declare a float variable and allocate a value.

    we print variable 'f' with different types:

    1 printf("f=%d\n", f);    //f=1610612736
    
    2 printf("f=%f\n", f);    //f=3.140000

    Claim that 'f' ought to contain a floating point value. But 'f' was shown in the illustration as an integer. Well, which is it, an integer or a floating point number? 

    The answer is that the variable contains a sequence of bits, 0's and 1's. They could be interpreted either as an integer or as a floating point number, depending on the manner in which they are used. If integer arithmetic instructions are used, the value is interpreted as an integer. If floating point instructions are used, it is a floating point number. The type of a value cannot be determined  simply by examining its bits. To determine its type (and therefore its value) you must  look at the way the value is used in the program.

你可能感兴趣的:(内存)