Programming Operators Full-Color Poster Infographic

- PDF

Description
High Resolution pdf format
PROGRAMMING OPERATORS
Mathematical Operators
Operator Meaning Example
+ Addition x=4+4 # x is 8
- Subtraction y=4-4 # y is 0
* Multiplication z=4*4 # z is 16
/ Division a=4/4 # a is 1
* Multiplication b=4*4 # b is 16
^ or ** Exponentiaton (language dependent) c=4**4 # c is 256
& or + String Concatenation d="4"+"4" # d is "44"
MOD or % Modulus (remainder of division) e=22%5 # e is 2
DIV Quotient (whole number division) f=22 DIV 5 # f is 4
Use the acronym BIDMAS to remember order of operation:
Brackets, Indices, Dvision/Multiplcation, Addition/Subtraction
Assignment Operators
Put a value in a container / variable or copy a value from one variable to another
- The equal sign = makes assignments
- The left side MUST be a variable
- The right side MUST evaluate to a value x=5
of the appropriate type
The right side may be:
- A literal value……………………………………………..…….……………...…….…….y=237.32
- Another variable………………………………………..…….……………...…….…….z=a
- An expression…………………………………………....…….…….…………..….…….b=c+25*d
- A function/method with a return value…….…….…………..….…….…….e=Math.floor(3.1415926)
Relational Operators
Return a boolean (true or false) value describing the numerical relationship of the two primitive operands
Operator Meaning Example
> Greater Than 15 > 10
< Less Than 3 < 99
== Equal To 10-5 == 2+3
>= Greater Than Or Equal To 17 >= 11
<= Less Than Or Equal To 14 <= 14
!= Not Equal To 175 == 175
Objects frequently require “deep comparison” using member methods.
object1==object2 # do the references point to the same object
object1.equals(object2) # compares instance values within each object
Boolean Operators
Return a boolean (true or false) value describing the logical relationship of the two boolean operands
Operator Meaning Example
AND && Returns true if and only if both operands are true TRUE&&FALSE==FALSE
OR || Returns false if and only if both operands are false TRUE||FALSE==TRUE
NOT ! Returns the opposite boolean value !TRUE==FALSE