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

Deeper Look: Math Operators

<p>Things are starting to fall into place: let's revisit the math operators and add a few new tricks and shortcuts. After taking a deeper look at defining and assigning <a href="/courses/video/5/157/Using-Variables.html">variables</a>, now it's time to go for Math Operators. Learning various types of math operators is necessary for anyone who wants to develop as a programmer. We have seen all types of arithmetic <a href="/course/basics/operators">operators</a> such as +, -, *, /, but we need to know about one more very important operator to use in a number of programs. it's defined as modulo and is abbreviated with the percentile symbol %.</p> <h2>Percentile (%) Operator</h2> <p>If we use this symbol for a and b: a%b; it divides a by b to the closest <a href="/courses/video/5/161/Numbers-int-And-unit.html">integer</a> quotient. The remainder is left over to be part of modulo. Hence, we can say that % is the operator which gives the reminder as output provided the quotient is an integer. For example, if we have 13%2, here the best possible division that can be performed keeping the quotient to an integer value is (13/2)=(6+remainder.) We can see that the quotient can't be 6.5 because it isn't an integer value, so it's limited to 6 with a remainder of 1. Therefore, 1 is considered to be the modulus of the equation 13%2. Your turn! What is 9%4? (9/4 = 2 with a remainder of 1: the answer is 1.)</p> <p>Consider another example where the dividend is an even number: <b>12%2;</b>. Here, division can be performed to the fullest extent and still the quotient is an integer. Therefore, this leaves a remainder of 0, which is the final value of 12%2. This operator is very useful not only for finding the remainder but also in various programs for finding Fibonacci series, whether a number is odd or even, etc. You will understand the use of this operator more as you move forward and start utilizing it while coding.</p> <h2>Incrementing and decrementing variables</h2> <p>Since we learned all the basic operators and their uses, we need to focus on how these operators are used in a program. We can use these operators and write the equations in the same way as we write in mathematical algebra. But there are a few shortcuts for writing math equations in programming which makes life easier for the user. Mostly we use math operators for incrementing or decrementing variables and their values, for example: <b>i=i+1</b>.; This will increment the value of i to i+1 before moving to the next line. When we start writing the code, we can minimize this equation and simply write <b>i++;</b> which has the same meaning. This is applicable for all types of operators such as <b>i**; i- -;</b> . Your turn! How would you easily write code to divide I by 3?</p> <p>If you answered <b>I/=3;</b> you win that one! These are also very useful while writing the conditions for controlled loops where we can either decrement the value using i-- or increment the value using i++.</p>

Intro

In our mission to learn how to become a developer, things are getting more complicated. We will learn about the importance of variables, brackets, operators and even talk more deeply about data types

01:52

What Opens Must Close

Quick detour - I want to let you in on a little secret. It's my favorite shortcut in the book and will help you manage the many brackets with which you work.

06:33

Addition

Let's study string addition! We will see how we add strings together and how we add numbers together. And if you think that isn't enough, we'll even look at error 1084 and figure out how to avoid it.

03:33

Mixing Strings and Numbers

When working with numbers and strings it's important to prevent Compiler (Flash) from automatically converting data so you'll not be automatically confused.

02:04

Converting Strings to Numbers

How do we take that string and let Flash know we actually want it to be a number? The answer is simple: learn a new function. This function type is called Casting.

01:16

Using Variables

So, we have variables and we know how to create them but how can we actually use them and for what? We agree, it's time to see them in action through this video.

06:15

What are Primitives?

It’s important to differentiate between primitive and complex data types in Flash. Have no clue what primitive values are, well jump in and let's figure it out!

02:09

Deeper Look: Defining Variables

Now that we know what variables are it's time to look deeper into their structure and how to play with them. Also, we'll learn about a new error type we can now check to avoid - Error 1120.

04:10

Deeper Look: Math Operators

Things are starting to fall into the right place! Lets revisit the math operators and add a few new tricks and shortcuts. Also learn about a new operator (%) used to find the modulus of two numbers.

05:36

Numbers, int And unit

Though all three types Number, int and uint are used to represent numbers, there are few minor differences between them which help us save time. Lets learn what are they and when should we use them

07:19

Boolean

Boolean are simple. They are really only place holders that can hold only two possible values: true or false (0 or 1, yes or no...) Lets learn how Boolean variables are used in programming.

01:48