void main() { if(-1 > 0U) printf("True\n"); else printf("False\n"); }
Is it processor dependent (big endian / little endian)?
From C99 6.3.1.8 :
[...] Otherwise, if the operand with an unsigned integer type has a rank greater than or equal to the ranks of the type of another operand, then the operand with an integer type sign is converted to the operand type with an unsigned integer type.
int unsigned int (. 6.3.1.1), -1 unsigned int. 6.3.1.3, (-1 + UINT_MAX + 1) % (UINT_MAX + 1) ( ), , , UINT_MAX , , , 0.
int
unsigned int
(-1 + UINT_MAX + 1) % (UINT_MAX + 1)
UINT_MAX
0
, C (-1 > 0U) true.
(-1 > 0U)
Endian-Dependent , x, , , x.
x
:
int x = 0x12345678; char* p = (char*)&x; char c = p[0]; // 0x12 on BE and 0x78 on LE
", , ", .
, - BE LE:
struct s {int a; int b;} x = {0x11223344,0x55667788}; int* p = (int*)&x; int i = p[0]; // 0x11223344 in both cases
- BE LE.
, .
Source: https://habr.com/ru/post/1524487/More articles:Linq query with group - c #Python maps a file system to a directory structure: it works, but how? - pythonКак заказать несколько элементов в Spring Безопасность, распределенную по нескольким файлам - javaЗапустите приложение .Net MVC5 на Mono - linuxSpring Данные JPA - инъекция зависимостей конкретного класса сущностей - springDragEvent.ACTION_DROP is never called - androidUnity: Injecting Multiple Registered PerResolveLifetimeManager Types - c #IOS 7 hide tab - ios7InvalidOperationException - тип не имеет доступного конструктора - unity-containerBlueImp Gallery - Different gallery for different images - jqueryAll Articles