Arthmetic Operations Flashcards
Operators
These are special symbols (or multiple symbols) which tell the program to perform a specific arithmetic, relational or logical operation on its data. Operates have to be used in a specific order of precedence ( this describes the order of execution) you may be familiar with this concept from using BIDMAS or BODMAS ( Brackets Indices /pOwers, Divide, Multiply, Add and Subtract.) In mathematics.
Modulo
When a number is divided into another, the remainder (REM) is called the modulo or modulus, (MOD), which is often useful in calculations carried out by code needing the number remaining after division.
Integer devision
This is simply when one integer (whole number) is divided by another and you are only concerned with the integer part of the result. In other words, the remainder (decimal)
Is discarded, (wiped out) e.g
Normally 10/4 = 2.5
But 10/4 = 2
Boolean operators
Boolean operators can be complex calculation but always end with a result of true or false.
In these examples
Opposite (NOT) Not diesel True
All of them (AND) Car and diesel False
Any of them (OR) Car to diesel True
Relational operators
Relational operators are frequently used in code, especially for conditions which control a branch into choice of coding routs.
In these examples
Pay has been set to 3.9 Cost has been set to 4
Equals Pay = Cost False
Less than Pay < Cost True
More than Pay > Cost False
Not Equal to Pay < > Cost True
Less than Or Equal to Pay < = Cost True More than or Equal to Pay >= Cost False
Date/time operators
Usually a date in program code is held internally as whole number
(the day count from 1/1/1900)
And time as the fractional part of a number,
E.g. 75 is 6pm , so 6pm on 17 October 2017 is held as 43 025.75, so simple arithmetic can often be used Excel had a known bug which calculates 1900 as leap year.
Other programming languages make it very difficult for that programmer to reach the underlying numbers. It is much easier and practical to use the date and time functions provided.