Using MySQL’s TIMESTAMP vs storing timestamps directly

Arguments for TIMESTAMP It implicitly stores data in UTC time zone. No matter what your session time-zone is. Useful if you need to use different time zones. You can have automated timestamping columns using DEFAULT CURRENT_TIMESTAMP or ON UPDATE CURRENT_TIMESTAMP (one column per table only until MySQL 5.6.5) You can use datetime function for date … Read more

What is going on with bitwise operators and integer promotion?

[expr.unary.op] The operand of ~ shall have integral or unscoped enumeration type; the result is the one’s complement of its operand. Integral promotions are performed. [expr.shift] The shift operators << and >> group left-to-right. […] The operands shall be of integral or unscoped enumeration type and integral promotions are performed. What’s the integral promotion of uint8_t … Read more

unsigned int and signed char comparison

Section 6.3.1.8, Usual arithmetic conversions, of C99 details implicit integer conversions. If both operands have the same type, then no further conversion is needed. That doesn’t count since they’re different types. Otherwise, if both operands have signed integer types or both have unsigned integer types, the operand with the type of lesser integer conversion rank … Read more

Overflowing of Unsigned Int

unsigned numbers can’t overflow, but instead wrap around using the properties of modulo. For instance, when unsigned int is 32 bits, the result would be: (a * b) mod 2^32. As CharlesBailey pointed out, 253473829*13482018273 may use signed multiplication before being converted, and so you should be explicit about unsigned before the multiplication: unsigned int … Read more