On the type of C language understanding, understanding and float have appreciated symbols unsigned

Recently because to start looking for work, so start again re-write the C language. Then re-learn again he found himself a lot of blind spots, so to sum up properly.

  1, understanding of C language type

  2, on the C language of understanding signed unsigned

  3, understanding of floating point numbers

  1, understanding of C language type

  We all know that usually there are many types of C language, such as int, char, float, of course, but there are a number of C language type struct our own definition, in C language application, we can consciously use this type to define a variable, then what what type? Variable is doing it?

  A: First of all we need to know, all of our programming in fact, plainly manipulate the computer's memory at the same time, but we can not directly manipulate memory, so we need to find some interfaces to manipulate the memory. So I think these interfaces is actually variable , such as our int a, then we can manipulate this memory through a.

    So what type is it? We have done in the implementation of computer code int a time? I think at least do two parts. The first is to specify a certain memory address. For example, the beginning of 0x11111 Memory section. The second is to specify the size of the memory, such as using int on the specified memory we can manipulate four bytes. In other words, the type of property is given to the memory variables .

    The above is my understanding of the types and variables.

  2, on the C language has signed and unsigned understanding of

    First thing to say about the integer in a total of three forms, namely unsigned integer, signed integer positive number indicates and have a negative representation of signed integers. Wherein unsigned integer range 0 to 2 32 such a range, the signed integer of 2 -31 and 2 31 is such a range, the difference is that the former can be used to represent the maximum bit numbers, the most significant bit and the latter only It can be used to represent symbols . And there is a signed integer representation of turn can be divided into two, which is a positive representation of its own, while the negative representation of all its positive position reversed plus 1.

    Another point to note , is that there are signed and unsigned sum result is unsigned .

    These are understood to have me sign the book and not the number of symbols.

  3, understanding of floating point numbers

    We float for example, float and int representation is completely different, first of all say what they are 32-bit machine, but it represents a completely different way. float may be divided into three parts, respectively, the first 32-bit (sign bit), from 31 to 23 bits (bit exponent, from 0 to bit 22 (bit mantissa).

    Wherein 32 represents the sign bit negative number, if it is 0 for positive, 1 for negative , in which the position 31 to the second 23 bits represent the exponent, mantissa bits from bit 0 to 22.

  Then I will give an example shows, yellow sign bit, exponent in green, brown mantissa bits.

    Example: 20.75 (decimal number)

     His frame is this:

      1, to become a binary integer bits

      2, binary to decimal places become

      3, so that the movement position intermediate between 0 and 1, and determining the value of exponent

      4, finalized indicate

   Wherein the converted 20-bit binary number, may be inverted using method 2 (00010100)

      0.48 becomes binary digits, to say here, if the bit is an integer of 2 Infinite addition we can use, we use the method of infinite decimal places multiplied by 2. So is 10 decimal places

      To sum up 20.75 to 10,100.10 become binary.

      Subsequently, it moves the position of the intermediate 0-1. 1.010010 * 2 to 4 it exponent is 4 + 127 = 131 (plus 127 is why I did not understand)

      Finally, we can determine its expressed as 0 10000011 1010010000000000000000.

      The above is my understanding of floating point numbers.

 

 

 

 

 

 

 

 

  

 

Guess you like

Origin www.cnblogs.com/songyuchen/p/12637564.html