Learning the underlying programming or reverse children's shoes, is certainly no stranger to these two terms?! Today, I will introduce you to these two concepts.
Popular science:
Big endian and little endian, foreigners called Big-Endian and Little-Endian, actually refer to the same Dongdong in the computer world, indicating the order in which data is stored in memory. Different CPUs and operating systems treat data in different ways, but the common operating systems are small endes, and the communication protocol is big endian.
But it is not that the system is a small-end form of storage, the file must be in the form of small endian, different applications have their own way of storing their own data (the data is loved by the data, some also disrupt the encryption). such as:
* Adobe PS -- Big End
* BMP -- Little End
* GIF -- Little End
* JPEG -- big endian
* MacPaint - Big End
* RTF -- Little End
So what is the difference between Little End and Big End? Everyone knows about a chestnut:
For example, 0x12345678 this number:
* The big endian method is stored in bytes in memory as: 12 34 56 78
* Little endian method is stored in bytes in memory in order: 78 56 34 12
Explanation:
Big endian: The higher valid byte is stored in the lower memory address, and the lower valid byte is stored in the higher memory address.
For example, the integer variable 0x12345678 occupies 4 bytes, so according to the memory address from small to large, they are stored as follows:
Little endian: The higher valid byte is stored in the higher memory address, and the lower valid byte is stored in the lower memory address. Therefore, the integer variable 0x12345678 is stored according to the memory address from small to large.
Conversion:
We found that a byte can hold two hexadecimal digits (the maximum number of bytes that can be stored is 0xFF), then if you give a decimal number (such as 112233), how to quickly know that it is in memory How is it stored?
l The big endian method is very easy, convert it directly into hexadecimal, and then store it in order: 0x0001B669
l The little endian rule is more troublesome, the steps are as follows:
* Convert to hexadecimal number (0x0001B669)
* Interchange the lower four digits and the upper four digits of eight digits (0xB6690001)
* In the lower four and upper four, swap two pairs (0x69B60100)
How to detect if your machine is big end or small end?
As I said before, most of the common personal computers use little endian, but we are all programs that change the world. Why do you think about how to use code to distinguish?
In fact, it is not difficult to determine the actual storage location by turning int to insert a single byte:
#include
Int main()
{
Int a = 0x2233;
Char *b = (char *)&a;
If (*b == 0x22)
{
Printf("大大!");
}
Else
{
Printf("å°ç«¯!");
}
Return 0;
}
Egg
Big end and little end, in fact, is the book Gulliver's Travels from Jonathan Swift.
The following is a description of Jonathan Swift's 1726 history of big and small disputes:
... What I want to tell you below is that the two powers of Lilliput and Blefuscu have been fighting hard for the past 36 months. The war started for the following reasons: We all think that before eating eggs, the original method is to break the larger end of the egg, but today the emperor’s grandfather eats eggs when he was a child, and happens to break a finger when he beats eggs according to the ancient method. Therefore, his father, then the emperor, ordered an order to order all the subjects to break the smaller end of the egg when eating eggs, and the offender was severely punished. The people are extremely disgusted with this order. History tells us that there have been six rebellions, one of which was sent to the emperor and the other lost the throne. Most of these rebellions were instigated by the kings of Blefuscu. After the rebellion subsided, the exiled people always fled to the empire to seek refuge. It is estimated that 11,000 people have been willing to die and will not break the smaller end of the egg. In this dispute, hundreds of books have been published, but the books of the big end are always banned. The law also stipulates that no one in the school can be an official...
In his time, Swift was satirizing the ongoing conflict between Britain (Lilliput) and France (Blefuscu). Danny Cohen, an early pioneer of network protocols, first used these two terms to refer to byte order, which was later widely accepted.
4 Port USb Charging
Ready to travel. The cable puts the charger on the table and extends to the distance from the power socket, and a travel adapter with foldable sales immediately turns it into a portable travel charger. This 4 -port USB charger has more protection safety systems to ensure the complete protection of you and your device. The mobile phone has its own charging circuit, which will be a adaptive current. No matter how much the power is, the phone can be charged safely.
4Port Usb Charger,Multi Port Usb Charger,Flat 4 Port Usb Charger,Wall Outlet 4 Usb Plugs
shenzhen ns-idae technology co.,ltd , https://www.best-charger.com