Purpose
Return value
Syntax
=GCD(number1,[number2],...)
- number1 - The first number.
- number2 - [optional] The second number.
Using the GCD function
The GCD function returns the greatest common divisor of two or more integers. The greatest common divisor is the largest positive integer that divides the numbers without a remainder. In other words, the largest number that goes into all numbers evenly.
The GCD function takes one or more arguments called number1 , number2 , number3 , etc. All numeric values are expected to be integers. Numbers with decimal values will be truncated to integers before a result is calculated. Each argument can be a hardcoded constant, a cell reference, or a range that contains multiple values. The GCD function can accept up to 255 arguments total.
Examples
To return the greatest common divisor of the numbers 60 and 36:
=GCD(60,36) // returns 12
GCD returns the number 12, since 12 is the largest factor that goes into both numbers evenly. To get the greatest common divisor of 12, 16, 48:
=GCD(12,16,48) // returns 4
In the example workbook shown above, the formula in F5 is:
=GCD(B5:D5)
As the formula is copied down, the GCD function returns a new result for each row, based on the values in columns B, C, and D. Empty cells are evaluated as zero.
Notes
- GCD evaluates empty cells as zero.
- GCD works with integers; decimal values are removed before calculation.
- If arguments contain a non-numeric value. GCD returns the #VALUE! error.
- To calculate the least common multiple, see the LCM function .
Purpose
Return value
Syntax
=INT(number)
- number - The number from which you want an integer.
Using the INT function
The INT function returns the integer part of a decimal number by rounding down to the integer. It is important to understand that the INT function returns the integer part of a decimal number, after rounding down . One consequence of this behavior is that negative numbers become more negative . For example, while INT(10.8) returns 10, INT(-10.8) returns -11. To return an integer by truncating decimals, see the TRUNC function .
The INT function takes just one argument, number , which should be a numeric value. INT returns a #VALUE! error if number is not a numeric value. If number is already a whole number, INT has no effect.
Examples
When numbers are positive, the INT function rounds down to the next lowest whole number:
=INT(3.25) // returns 3
=INT(3.99) // returns 3
=INT(3.01) // returns 3
Notice INT rounds positive numbers down toward zero . With negative numbers, INT rounds down away from zero :
=INT(-3.25) // returns -4
=INT(-3.99) // returns -4
=INT(-3.01) // returns -4
INT vs. TRUNC
INT is similar to the TRUNC function because they both can return the integer part of a number. However, TRUNC simply truncates a number, while INT actually rounds a number down to an integer. With positive numbers, and when TRUNC is using the default of 0 for num_digits , both functions return the same results. With negative numbers, the results can be different. INT(-3.1) returns -4, because INT rounds down to the lower integer. TRUNC(-3.1) returns -3. If you simply want the integer part of a number, you should use TRUNC.
Rounding functions in Excel
Excel provides a number of functions for rounding:
- To round normally, use the ROUND function .
- To round to the nearest multiple, use the MROUND function .
- To round down to the nearest specified place , use the ROUNDDOWN function .
- To round down to the nearest specified multiple , use the FLOOR function .
- To round up to the nearest specified place , use the ROUNDUP function .
- To round up to the nearest specified multiple , use the CEILING function .
- To round down and return an integer only, use the INT function .
- To truncate decimal places, use the TRUNC function .
Notes
- INT returns a #VALUE! error if number is not a numeric value.
- Use the INT function to get an integer from a number by rounding.
- Use the TRUNC function to return an integer by truncating.