Зміст курсу
Google Spreadsheets
Google Spreadsheets
Working with Numbers and Integers
Will explore the topic of Working with Numbers and Integers. Functions for working with numbers and integers allow you to round numbers to whole values, find remainders, and calculate absolute values. Let’s look at three key functions: INT, MOD, and ABS.
Extracting Integers
The INT function returns the integer part of a number by truncating decimal places. This function is useful when you need to round a number down to the nearest whole number, regardless of the decimal values.
Syntax and Examples
INT(value)
- value - The value you want to round down to the nearest whole number.
Formula | Result | Comment |
---|---|---|
INT(5) | 5 | The integer part of the number is 5. |
INT(5.3) | 5 | Rounds down to the nearest whole number, 5. |
INT(5.8) | 5 | Rounds down even when the decimal part is > 0.5. |
INT(5.88) | 5 | Truncates to 5 regardless of the decimal size. |
INT(-5.8) | -6 | For negative numbers, always rounds down further. |
INT(-5.3) | -6 | Always rounds down further for negatives. |
Calculating Modulus
The MOD function returns the remainder when one number is divided by another. This is useful for determining remainders, identifying even and odd numbers, and solving problems involving cyclic calculations.
Syntax and Examples
MOD(dividend, divisor)
- dividend - The number to divide to find the remainder;
- divisor - The number to divide by.
Formula | Result | Comment |
---|---|---|
MOD(5,5) | 0 | Remainder when dividing 5 by 5 is 0, as 5 is divisible by 5. |
MOD(7,5) | 2 | Dividing 7 by 5 gives 1 with a remainder of 2. |
MOD(3,5) | 3 | 3 is less than 5, so the result is the number itself, 3. |
MOD(0,5) | 0 | Dividing 0 by any number always yields a remainder of 0. |
MOD(5,0) | #DIV/0! | Error #DIV/0! occurs because division by 0 is undefined. |
MOD(-3,5) | 2 | The remainder of -3 divided by 5 is 2; the result is always non-negative. |
MOD(5,-3) | -1 | Dividing 5 by -3 yields a remainder of -1; the result can be negative. |
IF(MOD(5,2) = 0, "Even", "Odd") | Odd | MOD(5,2) calculates a remainder of 1, so the result is "Odd". |
Calculating Absolute Values
The ABS function returns the absolute value of a number, i.e., the number without its sign. This is useful for converting negative numbers to positive in calculations where only the magnitude matters.
Syntax and Examples
ABS(value)
- value - The number for which you want to return the absolute value.
Formula | Result | Comment |
---|---|---|
ABS(-10) | 10 | Returns the absolute value of the number. |
ABS(-10.643) | 10.643 | Removes the negative sign; result is 10.643. |
ABS(-10/4) | 2.5 | Dividing -10 by 4 gives -2.5; the absolute value is 2.5. |
ABS(10) | 10 | Positive numbers remain unchanged. |
Дякуємо за ваш відгук!