Tag: unsigned-integer
-
Emulating signed integers using unsigned integers in C
11 In Jens Gustedt’s book Modern C, on page 59, he explains how signed integers can be emulated using unsigned integers. His example code shows how one can implement a comparison of two unsigned integers reinterpreted as signed integers: bool is_negative(unsigned a) { unsigned const int_max = UINT_MAX /2; return a > int_max; } bool…