How to separate the number before and after the comma in Excel
Working with Excel spreadsheets, you often use it to calculate averages, percentages, etc. of numbers. The result returned will include the integer and the decimal part. Excel currently does not have a dedicated tool to separate the number before and after the comma. However, you can use available tools to calculate separate the integer and decimal parts. Read the following article to learn how to do it.
1. Get the number before the comma
Method 1: Use the TRUNC function
To separate the number before the comma, you just need to use the TRUNC function. This function will help you remove the digits after the comma, apply the following formula:
- TRUNC: a function used to round a number to an integer by removing its decimal part.
- Number: the original number before separating.
- Num_digits: a number that determines the precision of the cut. The default value of num_digits is 0 (none).
In the example below, we will remove the decimal part after the comma of the original numbers -12.52 and 12.52. Then you just need to enter as follows: =TRUNC (A2).
The result returned will be -12 as shown below. To use for the cell below, just drag the mouse down to the bottom and it’s done.
Method 2: Use the INT function
In addition, you can use the INT function to separate the number before the comma. Apply the formula =INT (A2) as shown below:
Then the result returned will be -13. Because the INT function rounds down to the nearest integer based on the value of the fractional part of that number. While the TRUNC function takes the integer part by removing its fractional part. Therefore, when the original number is negative, the result returned by these two functions will be different.
2. Get the number after the comma
The process is very simple after you get the number before the comma. To do this, you just need to subtract the result of the TRUNC function that you have calculated from the original number.
To make the steps faster, you can apply the following formula:
=original number – TRUNC(original number)
Applying it to the following example, you will get the corresponding result as shown below:
In case you want the result returned to be a positive number, you can use the ABS function. To get the absolute value, use the formula =ABS (original number – TRUNC (original number)). The following example will illustrate it more clearly for readers.
The article above provides you with two methods to separate the integer and decimal parts of a number in Excel. Apply it flexibly to suit your needs.