COMPSCI 2S03 Lecture Notes - Lecture 3: Operand, Type Conversion, Boolean Expression

49 views3 pages

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.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents