COMPSCI 2S03 Lecture Notes - Lecture 3: Operand, Type Conversion, Boolean Expression
Document Summary
Binary operators work with two operands (e. g. binary operators. Int to double is not lossy (no information is loss), all the data is conserved in double. 2. 0 is automatically a double, must specify float. Java automatically promotes to broader data type e. g. 4 + 8. 7, int 4 is converted to 4. 0 (floating point) to complete the operation. Double to int variable, some of the information is lost double numberofhours = 40. 65; int numberoffullhours = (int) numberofhours; Two different precedence, higher precedence will take priority. Evaluation is left to right 6 + 5 7, + has priority because of left to right despite same precedence. % and * have the same precedence int by int will result in an int integer division. Printf is a method in system. out, works with the dot operator. %d = digit (decimal number system for ints) %6d = prints whole value, right justified by 6 spaces.