CIS 1057 Chapter Notes - Chapter 4: Operand

22 views3 pages
Arithmetic Expressions cont.
Type Conversion through Casts
Programmers can change the type of a value via casts
Casts can be implicit (e.g. compiler casts) or explicit, when the programmer writes out (type)value
to change the value to the type specified
Expressions with Multiple Operators
Binary Operator = operator that takes two operands
e.g. multiplication (*) and division (/) operators
Unary Operator = operator that takes one operand
e.g. negation (-) and plus (+) operators
Rules for Evaluating Expressions
Parenthesis Rule
All expressions in parentheses are evaluated separately
Nested parentheses are evaluated from the inside out
Operator Precedence Rule
Operators in the same expression are evaluated in a specific order:
Unary first, /*% second, binary third
Associativity Rule
Unary operators are evaluated right to left
Binary operators are evaluated left to right
Unlock document

This preview shows page 1 of the document.
Unlock all 3 pages and 3 million more documents.

Already have an account? Log in

Document Summary

Programmers can change the type of a value via casts. Casts can be implicit (e. g. compiler casts) or explicit, when the programmer writes out (type)value to change the value to the type specified. Binary operator = operator that takes two operands e. g. multiplication (*) and division (/) operators. Unary operator = operator that takes one operand e. g. negation (-) and plus (+) operators. All expressions in parentheses are evaluated separately. Nested parentheses are evaluated from the inside out. Operators in the same expression are evaluated in a specific order: Unary operators are evaluated right to left. Binary operators are evaluated left to right. An error due to coding a real number as a finite number of binary digits. An error resulting from applying an arithmetic operation to operands of vastly different magnitudes, which causes the effect of the smaller operand to be lost. An error in which a very small computational result is represented as zero.

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