The endian-ness of a platform refers to the way the most significant byte is stored on that device. This information is highly important as many algorithms can be optimized based on this information. Notably, the two most popular rendering SDKs, DirectX and OpenGL, differ in their endian-ness. The two different types of endian-ness are called big endian and little endian.
In this recipe, we will find out how easy it is to find the endian-ness of a device.
Open Visual Studio.
Create a new C++ project.
Select Win32 Console Application.
Add a source file called
Source.cpp
.Add the following lines of code to it:
Source.cpp #include <stdio.h> #include <iostream> #include <conio.h> using namespace std; bool isBigEndian() { unsigned int i = 1; char *c = (char*)&i; if (*c) return false; else return true; } int main(...