A cast is an explicit conversion, written (type)expression. Converting a floating value to an integer type drops the fractional part (it truncates toward zero); converting an integer to a narrower unsigned type keeps it modulo .
int. Two signed or two unsigned operands meet at the greater rank, up their column (i). A signed operand goes to the unsigned operand’s type when that rank is equal or greater: right at the same rank, then up (ii). When the signed operand has the greater rank, the unsigned one moves to it along a dashed arrow if that type holds all its values, as unsigned into a 64-bit long; if not, both go to the unsigned type of the greater rank (iii). A floating operand makes the whole operation floating.Ejemplos
Example 2.5 (Why -1 < 1u is false)
In minus_one < one, both operands have rank int and one is unsigned, so by case (ii) minus_one is converted to unsigned: , which is not less than 1. In big < one, big is a long, of greater rank, and on this machine long can hold every unsigned value: by case (iii) one is converted to long, and is true. The same expression gives the opposite answer on a system where long has 32 bits: long then cannot hold 4294967295, so case (iii) sends both operands to unsigned long, and big becomes 4294967295 again.