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

Answer To Math Question

This video is a revision and practice to help understand new concepts learned in the last video. We'll follow all the steps mentioned in the previous video to get an answer to a complicated math equation. When we evaluate the equation according to the priority of the math symbols, the calculation becomes easier. So, practical knowledge on evaluating the math equation is a must before moving forward in the courses.

Lets review this with an example: (2-3)*3+8/(4-2). When we write this equation in trace without double quotes, Flash evaluates the final answer and prints it on the output panel. Let's now discuss the steps taken by Flash to evaluate the answer to this equation.

Firstly, the highest priority symbols will be evaluated as discussed earlier. We can see that the order of priority in this equation is

  1. () – whatever is in parenthesis is calculated first.
  2. * or / – multiplication or division next
  3. + or - – addition or subtraction last

So (2-3) and (4-2) are evaluated first which gives the first result: -1*3+8/2. We know that * and / are higher priority than + and -, so after the next evaluation the penultimate answer is -3+4. This is evaluated easily as 4-3 which gives the answer 1. Therefore anytime you need to calculate something in code strip out the complex parts based on the priority levels of (parenthesis, multiplication or division, and lastly plus or minus).

After watching this video, you might wonder how easy mathematics is. Yes, the part of math related with Flash is very simple as it's based on basic mathematical operations. If you need a refresher or you're finding yourself lost, please don't hesitate to contact your assigned trainer, use our community channels or contact us directly.

Video Transcript

00:00So let's decrypt this trace before we go into our next topic.
00:04So I'm just going to go here and kind of help myself a bit by grabbing this equation, duplicating, and let's put it inside of a separate line.
00:13And I'm using that double slash so it's not part of our application and it doesn't generate any errors, which, if we type something wrong, is going to generate errors, which we'll see in a moment.
00:25So if we run through this, first we said that things inside of brackets are in a higher priority, that things are out of the round brackets.
00:33So three minus one equals two. So we're first going to do that two times.
00:37And now we have a bracket inside of the bracket that we have a duplication that comes before minus.
00:45So two times four equals eight and two minus eight equals minus six.
00:50So I'm going to put the value here minus six inside of a bracket because we're duplicating it just to make it clear.
00:58And we have a last item, which is divide by two.
01:01Now, because everything here is in the same priority, we're going to go step by step.
01:07So two times minus six divided by two. And I can already see right now that I don't even have to do the math because two times and divide by two kind of cross each other out.
01:19So because they cross each other out, I know that the value is minus six.
01:23OK, but if you didn't know that, then two times minus six is minus twelve divided by two is minus six.
01:30So if you run the application one more time, and of course, I didn't save it.
01:34So let me save it and run it one more time. And the value is minus six.

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!