Introduction to Computer Science Notes - data storage

  This chapter is primarily concerned with how to use the various types of data stored in binary format inside the computer, there are several concepts, such computer-stored in the format called a binary bit pattern (bit pattern), which is a combination of 0 and 1 , sometimes called bitstream
  

  1. Store digital
    previous chapter may have been using the binary decimal conversion, but also solve the problem of the sign and decimal problems. There are different representations of different approaches for decimal point, are divided into fixed and floating point, when the first no fractional part of the digital processing as an integer, a decimal point which is not, nor with decimals,
    the second has decimal part

    1. Store integers
      store integers, when assuming that a decimal point, but not stored, if insufficient

      But this store has a problem, and now are basically 64-bit computer, the problem may be little overflow, if the computer is 4, then it is used to store the largest unsigned integer, then is the fourth power of 2, If outside this range will overflow, a maximum will be discarded, it is possible to use the real
      storage to store both integer, in order to use the computer's memory, unsigned integers, and signed integer is stored in a different way inside the computer.

      1. No notation
        unsigned integer is unsigned integer, the maximum value of the integer number of bits assigned to the computer by limiting, for example computer 64, a maximum value is minus 64th power of 2, a storage unsigned integer, first he converted into a binary number, if less than the median, to make up the zero on the left, if exceeded, it will
        overflow.

         The above diagram shows the state after the overflow, if your original number is 11, that is 1011, the machine is four loom, used to store the maximum unsigned integer that is a power of 2 minus 15 plus 11 9 when time, which should give 20, but because the overflow occurs, the first directly lost, the obtained
         result is 4.

        application of an unsigned integer: count, address (pointer) to other data types ordering

      2. Symbol plus absolute representation
        of this format to an unsigned integer in the effective range is divided into two equal methods, the first half of the range is a positive integer, the range of half a negative integer, the first digit represents the sign bit, 0 represents positive, 1 for negative

         It is noted that there are two zeros, respectively positive and negative 0 0.

        applications plus the absolute value symbol: store real numbers, sampled analog audio

      3. Two's complement representation
        highlight came, twos complement, I feel this notation is used to calculate the back will see the benefits of computing.

        First, some anti-code, complement.
        Anti-code: is the bitwise inverted

        Complement: a plus-minus

         One role of complement is modulo operation, as is the addition subtraction becomes, for example, 16 to I-mode is set, computing 15-2, in fact, I may be calculated by 2's complement, the complement 16,2 die 14, the equation becomes 15 + 14 is 29, as stated above unsigned integer we have the highest length, the length is actually die here, so
        29-16 = 13 (in binary is the highest loss), it is also the result of 15-2 13.
        so either complement or anti-code we have to solve the problem is to calculate, which are designed to achieve binary addition and subtraction, multiplication and division.

        When an integer of computer storage, if it is greater than or equal to an integer, 0 is stored directly, if the integer is negative, then the code storage complementation .

         The above figure shows goes complement binary representation of the number of each access method, and the absolute value symbols represent different method, the number of post-1000 this is not the increase, but decreasing, why do it? Quite simply, we conduct complement the 0001, 1111 is -1, it is this is in fact why the leftmost sign bit can participate in operations
        say is the sign bit, but do not understand it as a symbol, or understood as modular arithmetic, 0000-0111 take long complement, there must be a corresponding complement, such as 0111 to take complement is 1001, so the final analysis modular arithmetic, but we do not understand the first time to give people a symbol of the time (symbol the computer is not required), the first one must be 1, it is not good design, but the results of calculation, at the beginning of the code must complement integer is 1, and after the subtraction becomes an adder, a modulo operation lost if the most significant bit, to give is the correct number, in simple words, is negative subtraction, addition and then subtraction becomes, the rest is lost beyond the correct value, so people actually impose the sign bit up, but using the rules of modular arithmetic. This is why there is no reason to zero, because if zero, the number of the highest number in the mold can not take, and that is not negated yards.

  2. summary

  3. Storage real 

    The real number is a number with decimal and integer part, so if we use the words of the previous fixed-point representation will result in the loss of progress, for example, we store the number 0.01, then after the decimal point is not stored, the number after the decimal point will be lost. Solutions for representing real numbers are floating point.
    This representation allows for decimal floating up, it is actually converted to scientific notation

     

     After the conversion to scientific calculations we are only three places to store, symbol: positive and negative, index: binary number to the right of the decimal point: move the decimal digits of mantissa

    1. Coding system
      in order to allow storage of the index are positive, calculated without regard to the time symbol (in fact, this representation and complement almost), we must shift the entire system-digit number, if it is four, and that is biased 2 to the fourth shift -1

  4. IEEE Standards
    Institute of Electrical and Electronics Engineers defines a standard floating-point storage, basically we are very familiar with the single-precision and double-precision storage.

     Difference between the two is that the accuracy of the index is stored, the above single-precision offset is 8 th power of 2, that is below the 16 th power.

    Examples of directly on it. First negative judgment, is positive 5.75, s = 0, then converted to binary, 101.11, and then carrying out scientific notation, 1.0111 mantissa, exponent plus the offset 2,2 127 129 it is, so that E = 10000001, M 0111 is behind complement digits to the left of the decimal point 1 is not stored in binary as either 0 or 1.
    but when specified in scientific notation to the provisions of the decimal point set at a non-zero number, so it must be the one who It must be 1. 

     Book Zhongyuan words mean implicit, it is the implied meaning.

  5. 0 memory
    to store 0.0, the sign bit, the exponent, the mantissa are kept 0

  6. Truncation error
    even have a single-precision and double-precision, there will still exceed the maximum storage mantissa mantissa time, if this happens, the high number of bits will still cut off. This situation is called truncation error




 

  1. Storing text
    text that white is a symbol, expression symbolic significance of a language, we use different bit patterns to represent different symbols, so-called bit patterns, that is, the permutations and combinations of 0 and 1, for example, 0101 would be represented as "I" symbol, the world so many countries, so many languages symbol total number of bit patterns need it

     

     Is the number of symbols on the left, the right is needed to progress bit pattern is actually a log function of
    different bit patterns is designed to represent a set of text symbols, each set is called a code indicating the encoding process is referred to as the symbol

  2.  Store audio

    Text and numbers are with the number of entities can be, but there is no sound, we can not "record" sound, we can only record the sound density, a storage density audio asterisk.
    Even if it is stored in this way, we can not store all the values, because it is up to a myriad of memory.

     

     Per unit time signal over time, although we can not collect all of the signals, but we can record some of them, this is a sampling.

    Here also relates to the sampling rate, that is how much we need to collect data in order to ensure the sound closer to the original memory space between it and restore the sound to make a choice, the book gives a sampling of 40,000 per second is the number?

    Quantified: but also to quantify the samples, the world is at the sampled data is converted to an unsigned integer convenience store.

    Code: quantized sample values are also encoded, it is to choose the appropriate bit pattern, such as the previous 8-bit, and now the machine 64, it may be encoded as 64-bit. This is also known as bits per sample, each sample is stored bit. Multiplied by the number of samples per sample bit is the bit rate.

    Coding Standards:
      MP3: 16 bits per sample, 44100 samples per second bit

  3. Store images

    1. Raster
      raster image also known as a bitmap, the image is divided into a small box, and then record the data density of each small squares (color), see here, I feel that no matter what a multimedia form, are actually analog data analog audio, analog video, analog data as long as it would involve sampling, but the sound is a sampling of time-varying
      values, that is spatially variable sampling of the value of the image.

      Resolution: the number of pixels in each block to be recorded

      color depth: Number of bits used to represent a pixel, depends on the color of the pixel have different coding techniques to process

      1. True color: 24 bits to encode a pixel. Each RGB is represented as eight. Each primary color can be represented by a number between 0-255

      2. Index color
        true color can indicate the number of colors of the power of 24 2, but if you do not need so many colors it would use index. Choose from a number of true color in the color 256, which is then indexed, so they need only eight can guarantee the image will be normal, I feel that white is the color index sampling rate a bit, there are two such similar color, then the index colors take only one, if the pixel does not frankly high, indeed the use of such a situation, if the higher pixel is too high, the sampling rate, the larger the difference.

        jpg use true color, and use index gif

    2. Vector
      raster way to have some flaws, just can not be scaled and cropped, either the majority or reduced, or picture distortion (to expand the number of samples, but there is no store so much color) or is the picture loss of precision (after a number of narrow loss of color), the vector geometry is stored, the picture is stored as a set of graphic formula conversions.





       

       

       

       

       

       

  

 

 

  

    

 

 

  

Guess you like

Origin www.cnblogs.com/qunincey/p/11623257.html