02Geek HTML5 and JavaScript, TypeScript, React, Flash, ActionScript online School
Previous VideoNext Video

Rational Operators

We have seen the use of the equality operator and how it is different from the assignment operator. Similarly, Rational Operators also compare two variables and give the result as a Boolean value (true or false.) For Rational Operators we use angular braces or you can say angle brackets or even corner braces. However, we usually to refer them as "greater than symbol >" and "less than symbol <." Likely you now understand what type of symbols we are referring to. We use the same > and < which we used in mathematics in our primary school. In addition there are also two more rational operators which are formed by combining these symbols with the = sign. They are >= and <=, referred as 'greater than or equal to' and 'less than or equal to' respectively.

(>) Greater than Rational Operator

We use this operator to compare the two values or variables to check if one is greater than the other or not. The result is shown in Boolean values. For example, if we consider trace(a>b), the result will be true if 'a' is greater than 'b' and false if 'a' is either less than or equal to 'b'. One more example: trace(7>3), since 7 is greater than 3, the output is given as true. For trace(3>7), the output would be false.

(<) Less than Rational Operator

This is same logic as the one above but reversed. The compiler here checks whether one value is less than the other or not. For example, if we take trace(a<b). the result is true if the value of a is less than b and false if it is equal to or greater than b. If we consider trace(6<7) and trace(5<3), the result is true for the first one and false for the second one.

'Greater than or equal to'(>=) and 'Less than or equal to' (<=) Rational Operators

We have seen how to compare and find whether the first value is less than the second value or greater than the second value. There are cases where we need to find whether the first value is either 'greater than or equal to' to the second value or not. In such a case we use the symbol >=. Similarly, to check if the first value is either 'smaller than or equal to' the second value, we use the symbol <= for that comparison. For example if we take trace(6>=5), the result would be true which meets the greater than condition. If we consider trace(6>=6), the result is still same (true) because it meets the equality condition. Same is the case for trace(5<=6) and trace(6<=6), the result is true for both.

Ready to Level Up Your Skills?

Join thousands of learners on 02GEEK and start your journey to becoming a coding expert today!

Enroll Now for Free!

Overview

What are operators and why do we need them to create programs. We'll discuss various types of operators and their uses later in this course

01:49

Default Values

To understand operators, we first need to understand how variables work -- mainly when it comes to default values and why they differ for various variable types.

06:41

Equality

In this video we will compare between equality and assignment and learn how to work with both. We also differentiate between the assignment operator (=) and the equality operator (==)

06:40

Rational Operators

In this video we will see how to check if a variable is: bigger, smaller, greater or equals, smaller or equals and so on..... using rational operators

05:52

From Rational to Boolean

All the operators we worked with so far returned in our trace panel a value of true or false. In this video we'll see that connection of our operators results to the Boolean data type as we explore

05:26

Equality Operators

So far we've seen how to compare and see if values differ or match but we did not have a way to ask if not. In this sample we'll look into the equality operator(make it a bit more complex)

05:59

Comparison Between Different Types

In the heart of programming is the capability to compare between things. In this video we talk about comparing between different variable data types.

04:15

Explicit Equality

Sometimes knowing if something is equal just isn't enough and we need to know if it is explicitly equal and that's where explicit equality operator comes in...

08:05

Logical Operator

Logical operators enable us to compare a few things at a time such as AND, OR and NOT. We will learn the syntax to represent these operators using few examples

09:52

There Are Many Ways To Say No

doing exactly the oposite of the logical logic seams crazy but actually its a very great way to get things done. Let us learn how to say no in terms of programming

04:15

Null vs. Undefined

Why are there two ways of saying nothing? I ponder that as well as I try to explain their roles. In the process, we will learn the syntax and its application in code

06:20