Understanding of C++ data type computer storage

When I was reading the book Primer C++, there was always one thing I didn’t understand.
Insert picture description hereLater I thought
about it and I wanted to understand. Let’s talk about my own understanding, I hope you can give some guidance

Usually the data stored in the computer is stored in the way in the above picture. The four blocks in the above picture can be understood as a memory block composed of 4 bytes, one of which is equal to 8 bits/bit, so the above picture The memory block occupies 32 bits/bit
. The number in front of the box should be the address pointing to the memory

What I didn’t understand at the beginning was why float type data would occupy this block. Later, I figured it out. The book talked about bits, bytes, and words for a while, which confused me. Then I checked it and found
1 word. Section (byte) = 8 bits/bit (bit and bit mean bit)
1 word = 2 bytes

Then I went to understand the storage method of the float type in the memory. The float is stored in the form of sign bit, order code and end code. Generally, it occupies 4 bytes in memory, which is 32 bits. Then the size of this memory block is 32 bits, so this memory block is filled. The
char type occupies a byte in the memory, which is stored in the position 736424 in the above figure. The content in this position is the data of the char type. The above figure also says that the machine In the iso-latin-1 character set encoding format, so you can find the value corresponding to the position of 736424 in the iso-latin-1 character set.

The above is my understanding, please advise

Guess you like

Origin blog.csdn.net/jjswift/article/details/102900724
Recommended