Numerical Functions & Tricks In today’s lesson we will look at: why we might want to use mathematical techniques some useful functions other mathematical.

Slides:



Advertisements
Similar presentations
Visual Basic Statements Chapter 5. Relational Operators  OperationSymbol  Equal  =  Less than  <  Greater than  >  Not equal   Less than.
Advertisements

Rational Numbers and Opposites Enter the fraction,, as a quotient, and choose to have your answer displayed as a fraction by selecting ► FRAC, option 1,
Types and Arithmetic Operators
DATA REPRESENTATION CONVERSION.
CSE202: Lecture 2The Ohio State University1 Variables and C++ Data Types.
Percent (Concepts & Computation)
Arithmetic & Logic Unit Does the calculations Everything else in the computer is there to service this unit Handles integers May handle floating point.
Level ISA3: Information Representation
Mark Dixon, SoCCE SOFT 131Page 1 04 – Information Processing: Data-types, Variables, Operators & Functions.
Computer ArchitectureFall 2008 © August 25, CS 447 – Computer Architecture Lecture 3 Computer Arithmetic (1)
Bit Operations C is well suited to system programming because it contains operators that can manipulate data at the bit level –Example: The Internet requires.
A bit can have one of two values: 0 or 1. The C language provides four operators that can be used to perform bitwise operations on the individual bits.
Professor Jennifer Rexford COS 217
Texas Instruments TI-83 Plus Graphing Calculator Basic Operations.
Section 3.6 BUILT-IN FUNCTIONS involving numbers & strings.
Computer ArchitectureFall 2007 © August 29, 2007 Karem Sakallah CS 447 – Computer Architecture.
Mark Dixon, SoCCE SOFT 131Page 1 05 – Information Processing: Data-types, Variables, Operators & Functions.
MATHEMATICS Using a Calculator – The Basics. The aim of this powerpoint is to teach you techniques for using scientific calculators to solve complicated.
MATHEMATICS Division – Mental Methods. The aim of this powerpoint is to teach you further techniques for dividing numbers mentally. EITHER Take notes.
MATHEMATICS Converting between Mixed Numbers and Improper Fractions.
Storing data Getting data out Data types Ruby as a foundation Program Variables Click icon to hear comments (the download may take a minute)
Number Systems - Part II
Pascal Programming Strings, Arithmetic operators and output formatting National Certificate – Unit 4 Carl Smith.
Python Types Python values are of various “types” Ints, Floats, Strings, Characters, and more Two representations of numbers 1 vs 1.0.
CH09 Computer Arithmetic  CPU combines of ALU and Control Unit, this chapter discusses ALU The Arithmetic and Logic Unit (ALU) Number Systems Integer.
Number Systems CIT Network Math
MFM 2P Review – Core Skills Learning Goals: I can round whole numbers and integers I can convert from a percent to a decimal I can convert a number into.
LECTURE 4 IMA 101: Basic Math 6/17/ IMA101: Basic Mathematics.
Rational numbers. Whole numbers Whole numbers Rational numbers Whole numbers Natural numbers Integers / ¾ 18% A rational number.
CSE1222: Lecture 2The Ohio State University1. mathExample2.cpp // math example #include using namespace std; int main() { cout
Variables and Math in Code. Variables A variable is a storage block for information in your program “A” “A” Computer Program Memory Computer Program.
Arithmetic Expressions Russell Taylor NC Computing Software Application Development.
Data Representation, Number Systems and Base Conversions
COMPUTER PROGRAMMING I SUMMER Apply operators and Boolean expressions.
June 10, 2002© Howard Huang1 Number systems To get started, we’ll discuss one of the fundamental concepts underlying digital computer design:
Maths revision What maths can be used in the question? What strategies will help? What working do I need to show? Is the answer down to maths?
Dividing a Decimal by a Decimal. Dividing Whole Numbers 12 ÷ 2 = 120 ÷ 20 = 1200 ÷ 200 = ÷ 2000 = Multiply both 12 and 2 by 10 Multiply.
Computer Programming 12 Mr. Jean February 11 th, 2014.
B121 Chapter 5 Working with Numbers. Number representation ThousandHundredsTensUnits Natural numbers: 1,2,3,4,5……… Integers: Natural numbers.
Number Representation Lecture Topics How are numeric data items actually stored in computer memory? How much space (memory locations) is.
COMPUTER PROGRAMMING I SUMMER Apply operators and Boolean expressions.
Variables Continued In the last session we saw how variables are objects that allow us to store values in the RAM of the computer In this session we shall.
AHSGE NOTES Standard 1 – Objectives 1-4 The following slides have teacher’s notes and examples for understanding Standard 1, Objectives 1,2,3 and 4.
Transparency 2 Click the mouse button or press the Space Bar to display the answers.
The Hexadecimal System is base 16. It is a shorthand method for representing the 8-bit bytes that are stored in the computer system. This system was chosen.
Number Systems. ASCII – American Standard Code for Information Interchange – Standard encoding scheme used to represent characters in binary format on.
Converting to Percents. Decimals to Percents Decimals to Percents When converting decimals to percents, first you need to multiply the decimal with one.
Unit 2.6 Data Representation Lesson 1 ‒ Numbers
Type your name and send:
Imaginary & Complex Numbers
Expressions An expression is a portion of a C++ statement that performs an evaluation of some kind Generally requires that a computation or data manipulation.
CSE 102 Introduction to Computer Engineering
Number Systems Lab session 1 Xuan Guo.
2.0 COMPUTER SYSTEM 2.2 Number System and Representation
Decimals Lesson 1.
1. Number Systems.
Unit 2.6 Data Representation Lesson 1 ‒ Numbers
Computer Science 210 Computer Organization
Numerical Functions & Tricks
23 ×
More Maths Programming Guides.
Year 7 Number - Calculations
Digital Logic Design (CSNB163)
Chapter 8 Computer Arithmetic
Fractions, Decimals and Percentages
Data Types and Maths Programming Guides.
1. Number Systems Chapt. 2.
Presentation transcript:

Numerical Functions & Tricks In today’s lesson we will look at: why we might want to use mathematical techniques some useful functions other mathematical ideas

Computers are better at handling whole numbers (integers), and you can easily get rounding errors when working with long decimal numbers. You might need to write a program that performs a calculation – e.g. for a bank or insurance company You can use mathematical techniques for more interesting things, such as motion, or for cycling through a limited number of colours (like on the Spots theme for the ECOS web-site) Why Manipulate Numbers?

MOD: performs a division and gives you the remainder – e.g. 10 MOD 3 returns 1 MOD is useful if you want to cycle through a fixed number of options, e.g. dim c$(3) c$(1) = "Red" c$(2) = "White" c$(0) = "Blue" for n = 1 to 20 print n; " - "; c$(n MOD 3) next Useful Operations

Powers/Indices: to raise a number to a power, we use the ^ symbol (sometimes called a hat) For example, 4^3 would calculate 4 3 The sqr() function gives you the square root - e.g. sqr(16) returns 4 You can also use fractions like you do in GCSE Maths – e.g. 27^(2/3) returns 9 Useful Operations

abs(): gives you the absolute value of a number - i.e. without the sign. For example, abs(-1) would return 1 val(): gives you the numerical value of a string, e.g. val(“2.5”) would return the value 2.5. str$(): turns a number into a string, e.g. str(10) would would return a string containing “10”. Useful Functions

int() rounds a number down You must write a program or function to round in other ways, e.g. input "Give me a number: "; n input "How many decimal places? "; dp exp = 10^dp Print int(n*exp+0.5)/exp Rounding

You can change the sign of a number by multiplying by -1 You can use this idea to make things bounce – e.g. multiply their speed by -1 so that they go the other way, Computers are much better at working with whole numbers, so for things like money it is better to work in pence, and just divide by 100 when you want to display the answer Tricks & Tips

Boolean Operators – AND, OR, NOT Binary – representing numbers using only 0s and 1s Hexadecimal – used to describe colours Bitwise Boolean Operators: these take the Boolean Logical Operators and apply them to individual bits in the binary representation of numbers – this is how the binary flags page works. Further Reading