CS 3850 Lecture 5 Operators. 5.1 Binary Arithmetic Operators Binary arithmetic operators operate on two operands. Register and net (wire) operands are.

Slides:



Advertisements
Similar presentations
LECTURE 3: BASIC C OPERATORS. Objectives  In this chapter, you will learn about:  Arithmetic operators Unary operators Binary operators  Assignment.
Advertisements

1 Chapter 3:Operators and Expressions| SCP1103 Programming Technique C | Jumail, FSKSM, UTM, 2006 | Last Updated: July 2006 Slide 1 Operators and Expressions.
Chap. 6 Dataflow Modeling
1 9/24/07CS150 Introduction to Computer Science 1 Relational Operators and the If Statement.
All the Operators. Precedence An operator with higher precedence is done earlier (prededes) one with lower precedence –A higher precedence is indicated.
All the Operators. Precedence An operator with higher precedence is done earlier (prededes) one with lower precedence –A higher precedence is indicated.
Operators. Perl has MANY operators. –Covered in Chapter 3 of Prog.Perl Most operators have numeric and string version –remember Perl will convert variable.
More about Numerical Computation CS-2301, B-Term More about Numerical Computation CS-2301, System Programming for Non-Majors (Slides include materials.
Compunet Corporation1 Programming with Visual Basic.NET Arithmetic, Logical & Bitwise Operators Week # 3 Tariq Ibn Aziz.
Operations on data CHAPTER 4.
Chapter 4: Basic C Operators
Chapter 6. Dataflow Modeling. Continuous Assignments The left hand side always be a scalar or vector net or a concatenation of scalar and vector nets.
Programmable Logic Architecture Verilog HDL FPGA Design Jason Tseng Week 5.
CHAPTER:8 OPERATORS AND EXPRESSION IN C++ Prepared By Prepared By : VINAY ALEXANDER ( विनय अलेक्सजेंड़र ) PGT(CS),KV JHAGRAKHAND.
2440: 211 Interactive Web Programming Expressions & Operators.
Operators Using Java operators An operator takes one or more arguments and produces a new value. All operators produce a value from their.
Simple Data Types and Statements. Namespaces namespace MyNamespace { // …. { MyNamespace::func1() using namespace OtherNamespace; Comments: // /* xxxx.
CHAPTER 2 PART #4 OPERATOR 2 nd semester King Saud University College of Applied studies and Community Service Csc 1101 By: Asma Alosaimi Edited.
C Operators. CONTENTS CONDITIONAL OPERATOR SIMPLE ASSIGNMENT OPERATOR COMPOUND ASSIGNMENT OPERATOR BITWISE OPERATOR OPERATOR PRECEDENCE.
Basic Operators. What is an operator? using expression is equal to 9. Here, 4 and 5 are called operands and + is the operator Python language supports.
Selection Boolean What is Boolean ? Boolean is a set with only two values : –true –false true and false are standard identifiers in Pascal, called Boolean.
CSC 270 – Survey of Programming Languages C Lecture 5 – Bitwise Operations and Operations Miscellany.
C Programming Lecture 6 : Operators Lecture notes : courtesy of Ohio Supercomputing Center, and Prof. Woo and Prof. Chang.
C++ Basics Tutorial 6 Operators. What are going to see today? Assignment operator(=) Arithmetic operators(+,-,*,/,%) Compound assignment(+=,-=,*=……..)
Operators Precedence - Operators with the highest precedence will be executed first. Page 54 of the book and Appendix B list C's operator precedence. Parenthesis.
15-Nov-15 All the Operators. operators.ppt 2 Precedence An operator with higher precedence is done earlier (precedes) one with lower precedence A higher.
1 ITN270 Advanced Internet Databases Lecture 02. Operators and Function Reference Topics: – Explain & Demonstrate How You Can Use MySQL Operators – Overview.
1 Operators and Expressions. Expressions Combination of Operators and Operands Example 2 * y + 5 Operands Operators.
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
Assignment statement: Assigns a value to a variable Variable must appear on the left side, value on the right side of the assignment operator Right side.
1 Verilog Digital System Design Z. Navabi, 2006 Verilog Language Concepts.
C# Operator Overloading and Type Conversions C#.NET Software Development Version 1.0.
Principles of Programming Chapter 4: Basic C Operators  In this chapter, you will learn about:  Arithmetic operators  Unary operators  Binary operators.
Module 5 JavaScript Operators. CS346 Javascript-52 Examples  JS-5 Examples.
© 2005 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. Java Operator Precedence Operator Meaning Assoc. ===========================================================.
Expressions and Operators in C. Expressions and Operators Examples: 3 + 5; x; x=0; x=x+1; printf("%d",x); Two types: – Function calls – The expressions.
Operators & Expressions
Doing math In java.
OperatorstMyn1 Operators An operator is something that you feed with one or more values (or expressions, in programming jargon) which yields another value.
Department of Electronic & Electrical Engineering Expressions operators operands precedence associativity types.
What are Operators? Some useful operators to get you started.
ECE 103 Engineering Programming Chapter 4 Operators Herbert G. Mayer, PSU CS Status 6/19/2015 Initial content copied verbatim from ECE 103 material developed.
Expression and Operator. Expressions and Operators u Examples: 3 + 5; x; x=0; x=x+1; printf("%d",x); u Two types: –Function calls –The expressions formed.
Department of Electronic & Electrical Engineering Lecture 3 IO reading and writing variables scanf printf format strings "%d %c %f" Expressions operators.
Operators A binary operator combines two values to get one result: x OP y where OP is any binary operators such as +, -, *, /, ==, !=, >, &&, or even =.
 Most C programs perform calculations using the C arithmetic operators (Fig. 2.9).  Note the use of various special symbols not used in algebra.  The.
 Array ◦ Single & Multi-dimensional  Java Operators ◦ Assignment ◦ Arithmetic ◦ Relational ◦ Logical ◦ Bitwise & other.
CMPE-013/L: “C” Programming Gabriel Hugh Elkaim – Spring 2012 CMPE-013/L Operators Gabriel Hugh Elkaim Spring 2012.
OPERATORS IN C CHAPTER 3. Expressions can be built up from literals, variables and operators. The operators define how the variables and literals in the.
Rational Expressions relational operators logical operators order of precedence.
ECE 103 Engineering Programming Chapter 4 Operators Herbert G. Mayer, PSU Status 6/10/2016 Initial content copied verbatim from ECE 103 material developed.
CSE 220 – C Programming Expressions.
Operators and Expressions
University of Central Florida COP 3330 Object Oriented Programming
Rational Expressions. relational operators. logical operators
2.0 FUNDAMENTALS OF JAVA PROGRAMMING LANGUAGE
University of Central Florida COP 3330 Object Oriented Programming
Operators and Expressions
Lecture 5 from (Chapter 4, pages 73 to 96)
Character Set The character set of C represents alphabet, digit or any symbol used to represent information. Types Character Set Uppercase Alphabets A,
All the Operators 22-Nov-18.
Relational Operators Operator Meaning < Less than > Greater than
More about Numerical Computation
All the Operators 4-Dec-18.
Bit-wise and bit-shift operators
Introduction to Programming – 4 Operators
Expressions.
All the Operators 6-Apr-19.
All the Operators 13-Apr-19.
ENERGY 211 / CME 211 Lecture 5 October 1, 2008.
Presentation transcript:

CS 3850 Lecture 5 Operators

5.1 Binary Arithmetic Operators Binary arithmetic operators operate on two operands. Register and net (wire) operands are treated as unsigned. However, real and integer operands may be signed. If any bit of an operand is unknown ('x') then the result is unknown.

Operator Name Comments + Addition -Subtraction * Multiplication / Division Divide by zero produces an x, i. e., unknown. % Modulus

5.2 Unary Arithmetic Operators Operator Name Comments - Unary Minus Changes sign of its operand.

5.3 Relational Operators Relational operators compare two operands and return a logical value, i. e., TRUE(1) or FALSE(0). If any bit is unknown, the relation is ambiguous and the result is unknown. Operator Name Comments > Greater than >= Greater than or equal < Less than <= Less than or equal == Logical equality != Logical inequality

5.4 Logical Operators Logical operators operate on logical operands and return a logical value, i. e., TRUE(1) or FALSE(0). Used typically in if and while statements. Do not confuse logical operators with the bitwise Boolean operators. For example, ! is a logical NOT and ~ is a bitwise NOT. The first negates, e. g., !(5 == 6) is TRUE. The second complements the bits, e. g., ~{1,0,1,1} is 0100.

Operator Name Comments ! Logical negation && Logical AND || Logical OR.

5.5 Bitwise Operators Bitwise operators operate on the bits of the operand or operands. For example, the result of A & B is the AND of each corresponding bit of A with B. Operating on an unknown (x) bit results in the expected value. For example, the AND of an x with a FALSE is an FALSE. The OR of an x with a TRUE is a TRUE.

Operator Name Comments ~ Bitwise negation & Bitwise AND | Bitwise OR ^ Bitwise XOR ~& Bitwise NAND ~| Bitwise NOR ~^ or ^~ Equivalence Bitwise NOT XOR.

Operator Name Comments === Case equality The bitwise comparison includes comparison of x and z values. All bits must match for equality. Returns TRUE or FALSE. !== Case inequality The bitwise comparison includes comparison of x and z values. Any bit difference produces inequality. Returns TRUE or FALSE. 5.7 Other Operators

Operator Name Comments {, } Concatenation Joins bits together with 2 or more comma-separated expressions, e, g. {A[0], B[1:7]} concatenates the zeroth bit of A to bits 1 to 7 of B. << Shift left Vacated bit positions are filled with zeros, e. g., A = A << 2; shifts A two bits to left with zero fill. 5.7 Other Operators

Operator Name Comments >> Shift right Vacated bit positions are filled with zeros. ?: Conditional Assigns one of two values depending on the conditional expression. E. g., A = C > D ? B+3 : B-2; means if C greater than D, the value of A is B+3 otherwise B Other Operators

5.8 Operator Precedence The precedence of operators is shown below. The top of the table is the highest precedence and the bottom is the lowest. Operators on the same line have the same precedence and associate left to right in an expression. Parentheses can be used to change the precedence or clarify the situation. We strongly urge you to use parentheses to improve readability.

5.8 Operator Precedence unary operators: ! & ~& | ~| ^ ~^ + - (highest precedence) * / % + - > >+ == != === ~== & ~& ^ ~^ | ~| && || ?: