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

Comparison Between Different Types

<p>What happens when you compare different data <a href="/courses/video/5/161/Numbers-int-And-unit.html">types</a> in Flash? In this video we'll go over some of the basic operations when comparing different date types. The most valuable lesson you can take from this video is how Flash deals with such a comparison when working with a regular comparison operator(<a href="http://02geek.com/courses/video/7/58/Equality-Operators.html">’==' and '!='</a>.)</p> <p>In this course, we have compared different <a href="/courses/video/5/157/Using-Variables.html">variables</a> of the same data type. We used a number of <a href="/video/7/56/Rational-Operators.html">rational</a> and <a href="/courses/video/7/58/Equality-Operators.html">equality operators</a> to compare the variables or values which are of same type. Now we'll see how to compare the variables of different data types.</p> <p>Let us declare a variable 'a' with type int and a variable 'b' with data type <a href="/courses/video/4/156/Numbers-As-Our-Second-Variable.html">number</a>. Let the value be a=1 and b=2 which satisfies the respective data types. Now we can use trace(a==b) to check whether these two values are equal. If yes, you get true or else false. Here we can see that the two values are not equal and hence, the output is false. However, if we use <b>trace(a!=b)</b>, the result would be true because the comparison now is for inequality and the condition for inequality is met as the values are unequal. This was explained earlier too but now it is a kind of revision for us.</p> <p>You might think, comparing variables of type int with type Number is well and good, but what if the comparison is to be done between type <a href="/courses/video/5/161/Numbers-int-And-unit.html">int</a> and type <a href="/courses/video/5/162/Boolean.html">Boolean</a> (or type number and type Boolean?) We are going to discuss this here. We can explain this with the help of an example. Let's have variables a:int and b:Number . Assume that a=1 and b=0. Let's assign a Boolean variable now with value true:</p> <i>var isTrue:Boolean = true;</i> <p>We can say <b>trace(isTrue)</b> is true. If the value assigned to it is false then we get trace(isTrue) as false. Here we need to remember one thing that, a true value is considered to be 1 and a false value is considered to be 0 as said in the earlier videos.</p> <p>So now we have a=1,b=0 and isTrue = true (=1). If we try to compare int and Boolean variables we have <b>trace(a==isTrue)</b>, this will result as true. If we compare number type and Boolean type that is trace(b==isTrue), the result will be false because b=0 and isTrue=1 as it is true. Similarly, if isTrue is false then the value of isTrue=0, the results will now take a reverse shift.</p> <p>We have compared variables of different types whose value is either 0 or 1. But if the value of integer variable a is 5, and if we <b>trace(a==isTrue)</b>, the result would be false for both Boolean values (true or false) which is equal to 0 or 1. Neither 0 or 1 is equal to 5; the output will be false every time. In fact if we use the command <b>trace(a!=isTrue)</b>, the result would be true as it satisfies the inequality.</p> <p>One more key point we can take from this video is <b>never</b> use keywords as variables! We know that we can use any letter or word for a variable name but there are a few exceptions here as well. Data types and a few other keywords are already defined by the developers and are stored in the library for specific use. Therefore, usage of such keywords as variables in our program can cause problems. Hence, make sure that the <a href="/courses/video/5/157/Using-Variables.html">variables</a> declared don't match with any of the keywords.</p>

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