0% found this document useful (0 votes)
1 views31 pages

18 Programming Foundations - Bitwise Operators

The document provides an overview of computer operators, including mathematical, relational, and logical operators, along with their symbols and examples. It explains how these operators function in programming and includes practical examples to illustrate their use in decision-making scenarios. The author, Mohammed Abu-Hadhoud, has over 26 years of experience in the field.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views31 pages

18 Programming Foundations - Bitwise Operators

The document provides an overview of computer operators, including mathematical, relational, and logical operators, along with their symbols and examples. It explains how these operators function in programming and includes practical examples to illustrate their use in decision-making scenarios. The author, Mohammed Abu-Hadhoud, has over 26 years of experience in the field.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 31

Mohammed Abu-Hadhoud

ProgrammingAdvices.com
MBA, PMOC, PgMP®, PMP®, PMI-RMP®, CM, ITILF, MCPD, MCSD
Copyright© 2022 26+ years of experience
Mohammed Abu-Hadhoud
ProgrammingAdvices.com
MBA, PMOC, PgMP®, PMP®, PMI-RMP®, CM, ITILF, MCPD, MCSD
Copyright© 2022 26+ years of experience
Mohammed Abu-Hadhoud
ProgrammingAdvices.com
MBA, PMOC, PgMP®, PMP®, PMI-RMP®, CM, ITILF, MCPD, MCSD
Copyright© 2022 26+ years of experience
Computer Foundations

Operators

Mohammed Abu-Hadhoud
ProgrammingAdvices.com
MBA, PMOC, PgMP®, PMP®, PMI-RMP®, CM, ITILF, MCPD, MCSD
Copyright© 2022 26+ years of experience
Operator Types

Mohammed Abu-Hadhoud
ProgrammingAdvices.com
MBA, PMOC, PgMP®, PMP®, PMI-RMP®, CM, ITILF, MCPD, MCSD
Copyright© 2022 26+ years of experience
Computer Foundations

Mathematical
Operators

Mohammed Abu-Hadhoud
ProgrammingAdvices.com
MBA, PMOC, PgMP®, PMP®, PMI-RMP®, CM, ITILF, MCPD, MCSD
Copyright© 2022 26+ years of experience
Mathematical Operators
Operator Computer Symbol Example
Operation Results
Addition + 3.0 + 4.2 7.2

Subtraction - 8.5 – 4.0 4.5

Multiplication * 5*5 25

Integer Division / 10 / 5 2

Modulo Division Mod 9 Mod 4 1

Power ^ 3^2 9

Mohammed Abu-Hadhoud
ProgrammingAdvices.com
MBA, PMOC, PgMP®, PMP®, PMI-RMP®, CM, ITILF, MCPD, MCSD
Copyright© 2022 26+ years of experience
Computer Foundations

Relational Operators

Mohammed Abu-Hadhoud
ProgrammingAdvices.com
MBA, PMOC, PgMP®, PMP®, PMI-RMP®, CM, ITILF, MCPD, MCSD
Copyright© 2022 26+ years of experience
Relational Operators
Operator Computer Symbol Example
Operation Results
Equal to
= 5=7 False

Less than
< 5<7 True

Grater than
> 5>7 False

Less than or equal to


<= 5 <= 7 True

Grater than or equal to


>= 5 >= 7 False

Not equal to
<> 5 <> 7 True

Mohammed Abu-Hadhoud
ProgrammingAdvices.com
MBA, PMOC, PgMP®, PMP®, PMI-RMP®, CM, ITILF, MCPD, MCSD
Copyright© 2022 26+ years of experience
Computer Foundations

Logical Operators

Mohammed Abu-Hadhoud
ProgrammingAdvices.com
MBA, PMOC, PgMP®, PMP®, PMI-RMP®, CM, ITILF, MCPD, MCSD
Copyright© 2022 26+ years of experience
Computer Foundations

Logic in Marriage

Mohammed Abu-Hadhoud
ProgrammingAdvices.com
MBA, PMOC, PgMP®, PMP®, PMI-RMP®, CM, ITILF, MCPD, MCSD
Copyright© 2022 26+ years of experience
Logic in
Marriage Life

Husband Wife Result


True False True
True True True
False True True
False False True
Mohammed Abu-Hadhoud
ProgrammingAdvices.com
MBA, PMOC, PgMP®, PMP®, PMI-RMP®, CM, ITILF, MCPD, MCSD
Copyright© 2022 26+ years of experience
Logic in Computer

Mohammed Abu-Hadhoud
ProgrammingAdvices.com
MBA, PMOC, PgMP®, PMP®, PMI-RMP®, CM, ITILF, MCPD, MCSD
Copyright© 2022 26+ years of experience
Logical Operators

Mohammed Abu-Hadhoud
ProgrammingAdvices.com
MBA, PMOC, PgMP®, PMP®, PMI-RMP®, CM, ITILF, MCPD, MCSD
Copyright© 2022 26+ years of experience
“AND”
Operators

Mohammed Abu-Hadhoud
ProgrammingAdvices.com
MBA, PMOC, PgMP®, PMP®, PMI-RMP®, CM, ITILF, MCPD, MCSD
Copyright© 2022 26+ years of experience
Logical Operators
Operator Computer Symbol Example
Operation Results
And
AND True AND True True

Or
OR True OR False True

Not
NOT NOT True False

Mohammed Abu-Hadhoud
ProgrammingAdvices.com
MBA, PMOC, PgMP®, PMP®, PMI-RMP®, CM, ITILF, MCPD, MCSD
Copyright© 2022 26+ years of experience
Logical Operators

True  1
(5 > 3)  True
False 0

(5 > 7)  False
(5 > 3) AND (5>7)  False
True False 0
Mohammed Abu-Hadhoud
ProgrammingAdvices.com
MBA, PMOC, PgMP®, PMP®, PMI-RMP®, CM, ITILF, MCPD, MCSD
Copyright© 2022 26+ years of experience
Practical Example to learn “AND” operator:
IF you wan to get hired you have to have all the following
conditions:

1. Your Age must be >= 21 years


2. You should have a driver license.

This in computer means:


(Age>=21 AND HasDriverLicesne=True) Then will be hired

Mohammed Abu-Hadhoud
ProgrammingAdvices.com
MBA, PMOC, PgMP®, PMP®, PMI-RMP®, CM, ITILF, MCPD, MCSD
Copyright© 2022 26+ years of experience
Logical “AND” Operator:

Condition A Condition B A AND B


Age Has Driver License
25 >= 21  True Yes  True True
25 >= 21  True No  False False
19 >= 21  False Yes  True False
19 >= 21  False No False False

Mohammed Abu-Hadhoud
ProgrammingAdvices.com
MBA, PMOC, PgMP®, PMP®, PMI-RMP®, CM, ITILF, MCPD, MCSD
Copyright© 2022 26+ years of experience
AND Any “False” in AND the
result is False
A B A AND B
1 1 1
A B A AND B 1 0 0
0 1 0
True True True
0 0 0

True False False

False True False

False False False

Mohammed Abu-Hadhoud
ProgrammingAdvices.com
MBA, PMOC, PgMP®, PMP®, PMI-RMP®, CM, ITILF, MCPD, MCSD
Copyright© 2022 26+ years of experience
“OR”
Operators

Mohammed Abu-Hadhoud
ProgrammingAdvices.com
MBA, PMOC, PgMP®, PMP®, PMI-RMP®, CM, ITILF, MCPD, MCSD
Copyright© 2022 26+ years of experience
Logical “NOT” Operators

True  1
(5 > 3)  True
False 0

(5 > 7)  False
(5 > 3) OR (5>7)  True
True False 0
Mohammed Abu-Hadhoud
ProgrammingAdvices.com
MBA, PMOC, PgMP®, PMP®, PMI-RMP®, CM, ITILF, MCPD, MCSD
Copyright© 2022 26+ years of experience
Practical Example to learn “OR” operator:
IF you wan to get hired you have to have at least One the
following conditions:

1. Your Age must be >= 21 years


2. You should have a driver license.

This in computer means:


(Age>=21 OR HasDriverLicesne=True) Then will be hired

Mohammed Abu-Hadhoud
ProgrammingAdvices.com
MBA, PMOC, PgMP®, PMP®, PMI-RMP®, CM, ITILF, MCPD, MCSD
Copyright© 2022 26+ years of experience
Logical “OR” Operator:
Condition A Condition B A OR B
Age Has Driver License
25 >= 21  True Yes  True True
25 >= 21  True No  False True
19 >= 21  False Yes  True True
19 >= 21  False No False False

Mohammed Abu-Hadhoud
ProgrammingAdvices.com
MBA, PMOC, PgMP®, PMP®, PMI-RMP®, CM, ITILF, MCPD, MCSD
Copyright© 2022 26+ years of experience
OR Any “True” in OR the
result is True
A B A OR B
1 1 1
A B A OR B 1 0 1
0 1 1
True True True
0 0 0

True False True

False True True

False False False

Mohammed Abu-Hadhoud
ProgrammingAdvices.com
MBA, PMOC, PgMP®, PMP®, PMI-RMP®, CM, ITILF, MCPD, MCSD
Copyright© 2022 26+ years of experience
“NOT”
Operators

Mohammed Abu-Hadhoud
ProgrammingAdvices.com
MBA, PMOC, PgMP®, PMP®, PMI-RMP®, CM, ITILF, MCPD, MCSD
Copyright© 2022 26+ years of experience
Logical “NOT” Operator:
Condition A NOT A

True False
False True

Mohammed Abu-Hadhoud
ProgrammingAdvices.com
MBA, PMOC, PgMP®, PMP®, PMI-RMP®, CM, ITILF, MCPD, MCSD
Copyright© 2022 26+ years of experience
Logical “NOT” Operators

True  1
NOT (5 > 3)  False
False 0

NOT (5 > 7)  True

1
Mohammed Abu-Hadhoud
ProgrammingAdvices.com
MBA, PMOC, PgMP®, PMP®, PMI-RMP®, CM, ITILF, MCPD, MCSD
Copyright© 2022 26+ years of experience
Mohammed Abu-Hadhoud
ProgrammingAdvices.com
MBA, PMOC, PgMP®, PMP®, PMI-RMP®, CM, ITILF, MCPD, MCSD
Copyright© 2022 26+ years of experience
Solve the following problems:
12 >=12 NOT (12 >=12) 1 AND 1 (7 = 7) and (7 > 5)

12 > 7 NOT (12 < 7) True AND 0 (7 = 7) and (7 < 5)

8 < 6 NOT (8 < 6) 0 OR 1 (7 = 7) OR (7 < 5)

8 = 8 NOT (8 = 8) 0 OR 0 (7 < 7) OR (7 > 5)

12 <= 12 NOT (12 <= 12) Not 0 NOT (7 = 7) and (7 > 5)

7 = 5 NOT (7 = 5) Not (1 OR 0) (7 = 7) and Not (7 < 5)

Mohammed Abu-Hadhoud
ProgrammingAdvices.com
MBA, PMOC, PgMP®, PMP®, PMI-RMP®, CM, ITILF, MCPD, MCSD
Copyright© 2022 26+ years of experience
Mohammed Abu-Hadhoud
ProgrammingAdvices.com
MBA, PMOC, PgMP®, PMP®, PMI-RMP®, CM, ITILF, MCPD, MCSD
Copyright© 2022 26+ years of experience

You might also like