Presentation is loading. Please wait.

Presentation is loading. Please wait.

ICS 3U Math Class. ActionScript 3 – Math Class Rounding ceil – closest integer >= number (rounds up) floor – closest integer <= number (rounds down) round.

Similar presentations


Presentation on theme: "ICS 3U Math Class. ActionScript 3 – Math Class Rounding ceil – closest integer >= number (rounds up) floor – closest integer <= number (rounds down) round."— Presentation transcript:

1 ICS 3U Math Class

2 ActionScript 3 – Math Class Rounding ceil – closest integer >= number (rounds up) floor – closest integer <= number (rounds down) round – rounds to the nearest integer (follows rules of rounding)

3 ActionScript 3 – A Math Class Calculations max – returns the largest number in a list min – returns the smallest number in a list pow – will calculate the power of a number (specify the number and the exponent) sqrt – will calculate the squareroot of a number

4 ActionScript 3 – A Math Class Common Constant PI – contains the number 3.141592653589793 Can use this is calculations

5 ActionScript 3 – A Math Class Random Numbers Random will generate a random number between 0 and 1 Need to use floor and some calculations to make the random number within a range

6 ActionScript 3 – A Math Class Examples newnum = Math.ceil(num); newnum = Math.floor(num); maxnum = Math.max(num1, num2, num3, num4); newnum = Math.pow(num, 4); randnum = Math.floor(Math.random() * (1 + high – low) + low); newnum = Math.round(num); numsqrt = Math.sqrt(num); circlearea = 2 * Math.PI * (radius^2);

7 Modulo % - A Math Operator The modulo math operator calculates the remainder of a division. Examples:  8 % 6 would equal 2 (8 divided by 6 is 1, with 2 remaining)  10 % 3 would equal 1 (10 divided by 3 is 3, with 1 remaining)  22 % 11 would equal 0 (22 divided by 11 is 2, with 0 remaining) When a modulo calculation results in 0, you know that the numbers are evenly divisible. Common uses are: –to determine if a number is even (num % 2 == 0), or –to separate the digits of a number (onesdigit = num % 10).

8 Programming Exercises 1.Adapt the Circle Calculation program to use PI 2.Adapt your smallest of three numbers to use min. 3.Generate a random number with 3 digits and output each digit separately. (You do not need a stage!)


Download ppt "ICS 3U Math Class. ActionScript 3 – Math Class Rounding ceil – closest integer >= number (rounds up) floor – closest integer <= number (rounds down) round."

Similar presentations


Ads by Google