ICS 3U - PowerPoint PPT Presentation

About This Presentation
Title:

ICS 3U

Description:

ICS 3U Math Class ActionScript 3 Math Class Rounding ceil closest integer = number (rounds up) floor closest integer – PowerPoint PPT presentation

Number of Views:60
Avg rating:3.0/5.0
Slides: 9
Provided by: OCD113
Category:
Tags: ics | actionscript

less

Transcript and Presenter's Notes

Title: ICS 3U


1
ICS 3U
  • Math Class ?

2
ActionScript 3 Math ClassRounding
  • ceil closest integer gt number (rounds up)
  • floor closest integer lt number (rounds down)
  • round rounds to the nearest integer (follows
    rules of rounding)

3
ActionScript 3 A Math ClassCalculations
  • 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 ClassCommon Constant
  • PI contains the number 3.141592653589793
  • Can use this is calculations

5
ActionScript 3 A Math ClassRandom 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 ClassExamples
  • 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 (radius2)

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
  • Adapt the Circle Calculation program to use PI
  • Adapt your smallest of three numbers to use min.
  • Generate a random number with 3 digits and output
    each digit separately. (You do not need a stage!)
Write a Comment
User Comments (0)
About PowerShow.com