当前位置:网站首页>storage of data in memory

storage of data in memory

2022-08-10 03:19:00 Cxz_learn_C

1. There are three representation methods for integers in the computer, namely original code, inverse code and complement code

Unsigned integer, the original code of signed positive integer in memory, one's complement and one's complement are the same.

The original code, inverse code and complement code of signed negative integers in memory are different. The specific conversion methods are as follows:

Integers are stored in memory in two's complement, and they are also used in calculations.Reason: Two's complement can perform operations on the sign bit and subtraction.Here's an example:

2. Data is stored in memory at the big and small ends

Size-end storage is a storage method for data whose type size exceeds 1 byte. Note that if the data size is 1 byte, then the data inside the byteNo need to store in endianness.

Big-endian (storage) mode: means that the low-order bits of data are stored in the high address of the memory, and the high-order bits of the data are stored in the low address
of the memory.

Little-endian (storage) mode: means that the low-order bits of data are stored in the low address of the memory, and the high-order bits of the data are stored in the high address
of the memory.

The above two storage modes are for the storage of data whose data type is greater than 1 byte.Different compilers have different data storage modes. Currently I use little endian storage on vs2019.High bits raise the address, and status lowers the address.

3. The range of char type that can store data in memory

As shown:

For the convenience of readers' understanding, the following pictures are used for reference:

The same int type, the short type is also stored in this way.

原网站

版权声明
本文为[Cxz_learn_C]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/222/202208100137298907.html