3.1.1.3 Arithmetic operations in a programming language. Flashcards
Addition.
int num = 7 + 7;
Subtraction
int num = 7 - 4;
Multiplication.
int num = 7*5;
Real/Float Division.
int num1 = 9;
int num2 = 9;
Float v = (float) num1/num2;
Integer Division including Remainders.
int division:
int num = 7 /1;
Remainders:
int i = 10;
int j = 3;
int k = i%j;
Exponentiation.
An exponent is a quantity representing th power to which a given expression is to be raised e.g. 5^4
Math.pow(base , exponent );
Rounding.
Math,round( );
What is truncation?
To trim or cut some digits of a float or double-type number or some character of a string from the right. Cn also be used to truncate the decimal portion completely that makes it an integer.
Define the syntax for truncation.
truncateNumber(num, digits);