1 1 vote If f is a float and n an int, then the expression (n > 0) ? f : n is of type float regardless of whether n is positive. Why? Programming in C + – Vishal Goel 659 views answer comment Share Follow Print 0 reply Please log in or register to add a comment.
0 0 votes Information loss is a major concern. For an operator with operands of different types the operands are converted to a common type, generally from a narrower to a wider operand without losing information. In simple terms more number of bits to represent the information. "If f is a float and n an int, then the expression (n > 0) ? f : n is of type float regardless of whether n is positive." Here the n gets converted to the type float and regardless of what n is the result is of type float. One can read rules of type conversion from the standard. ( http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4296.pdf , page 129) Srinath Jayachandran answered May 6, 2017 Srinath Jayachandran comment Share Follow 0 reply Please log in or register to add a comment.