E81 CSE 131 Lecture Notes - Lecture 1: Empty String, Decimal Mark, Master Sergeant

23 views4 pages
magentarat813 and 20 others unlocked
E81 CSE 131 Full Course Notes
8
E81 CSE 131 Full Course Notes
Verified Note
8 documents

Document Summary

We can combine types in expressions where this makes sense. If two types participate in an expression, the result is usually of the more general type. The double type is more general than the int type. We can represent any int as a double. No way to represent 0. 5 as an int double radius = 2; Allowed, but we lose the data after the decimal point. The conversion requires the explicit cast, shown as (int) Result will just be 3 int avg = (2 + 3) / 2; The result is computed in integer arithmetic, so the value assigned to avg is 2 double avg = (2 + 3) / 2; The right-hand side is computed first, resulting in 2. Results in value 2. 0 for the avg double avg = (double) (2 + 3) / 2; (double) 1 / 2 + 2 / 3 + 3 / 4. It is overloaded from arithmetic for int and double types.

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