Splitting a number into integer and decimal portions
Here is a quick formula tip to start another awesome week.
Often while working with data, I need to split a number in to integer and decimal portions. Now, there are probably a ton of ways you can do this. But here are two formulas I use quite often and they work well.
Assuming the number is in cell A1,
 Integer part =INT(A1)
 Decimal part =MOD(A1,1)
These formulas work whenever my data has only positive numbers (which is the case 90% 0f time). But if I am dealing with a mix of positive and negative numbers, I use,
 Integer part
=INT(A1) +(A1<0)=TRUNC(A1,0) [thanks to Somnath for suggesting this]  Decimal part =MOD(A1,SIGN(A1))
What formulas do you use to process numbers?
I use a lot of formulas while working with numbers. But my favorite ones are MOD, INT, SIGN, ABS, RAND and RANDBETWEEN (new in Excel 2007, requires Analysis toolpak in earlier versions).
What about you? What formulas do you use and how do you process your numbers? Please share using comments.
Learn more quick tips & formula examples.
 
 

Leave a Reply
VLOOKUP Formula Cheatsheet – FREE Download  An Excel Dashboard to Visualize 10,007 Comments [Dashboard Tutorial] 
26 Responses to “Splitting a number into integer and decimal portions”
interested to know about this =INT(A1) +(A1<0)
wat's the purpose of +(A1<0) ?
i traced it and it gave it as TRUE.
thanks!
@David: Excel treats TRUE as 1 and FALSE as 0. Since INT(negative number) will give a value 1 less than expected, I want to add 1 to it whenever a number is negative and 0 if the number is positive. So the expression (A1<0) will be TRUE or FALSE based on the sign of A1. Now, if you add this to another number, excel converts the TRUE to 1 and FALSE to 0.
Hope that makes sense.
Number in A1
For Integers
In B1
=TRUNC(A1,0)
For Decimal
In C1
=A1B1
To split numbers (negative or positive) I use =TRUNC(A1,0) then to get the decimal =A1A2 assuming =TRUNC(A1,0) is in cell A2.
Woops – just saw Sam’s post!
Formulas to split positive decimal numbers are used to separate dates into days and hours.
I like to operate with fractions typed as:
A1 = 0 5/8
A2 = 2 1/8
A3 = A1 + A2 = 2 3/4
One of my friends had a requirement to separate X and Y coefficients from a string received from CAD software.
The string would look like x123.234y234.56.(X will be always in the first place but Y place is not fixed as it would depend on integer and Decimal places of X coefficient)
Here is one of the solutions:
Assuming
Cell A1 > x123.234y234.56
Enter Cells B1> =FIND(“x”,A1,1) – to find the place of X in the string (it will be always 1)
Enter CellsC1 >=FIND(“y”,A1,1) – find Place of Y (position depends on X Coeff.)
Enter Cells D1 > =MID(A1,B1+1,C12) – to get X coeff.
Enter Cells E1 > =MID(A1,C1+1,LEN(A1)C1)
Hope this would be helpful for those who take help of Excel while working on Mechanical design software.
There is a better and easier way :
Assuming Cell A1 contains : x123.234y234.56
Then
=MID(A1,2,FIND(“y”,A1,1)2) – Would give you the X value
and
=MID(A1,FIND(“y”,A1,1)+1,LEN(A1)FIND(“y”,A1,1)) – Would give you the Y Value
without much fuss
Chandoo,
your blog (Splitting a number into integer and decimal portions) on these two formulas helps me a lot to solve a big problem at my office. Really awesome blog. Thanks Chandooo.
THANKS A LOOOOOOOOOOOOOOT.
Keep it up.
Good, but whts the significance of typing 1(divisior) in case of decimal formula. I typed 2,3…. got the same result….
@Eamon & @Sam: Thanks for the tip on TRUNC(). I did not know about it earlier.
@Pedro: I use it for splitting days and time as well. Also, do you know you can show fractions in excel with custom format code – # ?/?
@Shashi..good tip, thanks for sharing.
@Kalyan: I am so glad you find this tip useful.
@Prateek: The result for 2, 3 will not be same as 1. Check it with multiple values. the fraction portion of a number is nothing but what remains after you remove nearest multiple of 1. (essentially mod(number,1) )
Chandoo,
Since =INT(A1)+(A1<0) on a whole negative integer (with no decimal parts) E.g: 7.00 will return 6, I think the TRUNC function is more effective.
Hi Chandoo…..Can we apply more than one for formula for a cell or a selected range of cell???If we can then how could we…explain with a simple example.
Regards
Raiyan
Chandoo, using fraction format “As Hundreds” or custom format – # ?/100, decimal number 12.23 can be represented as 12 23/100.
This fraction format only split decimal numbers visually, but is awesome to me.
Thanks Sam & Emon for trunc
float a, c, d=0;
int c
while(a!=0)
{
c= a*10;
d= d*10 + c;
a=a*10 – c;
}
How do I split $84,000 in a 12 month period with july and August having equal amounts? What formula can I use? Thank you.
thanks, this helped me a lot with my formula!
14294,5,8,9,11,1317
hi ,
in this number series how to take a total count in excel?
@Krish
Apologies, I have missed your question
What number should the series 14294,5,8,9,11,1317 return ?
Hi Chandoo, I. Need to know what formula to use if I want the decimal values to add up separately ie 47.6+48.5=95.11. Every time the decimal value exceeds 9, it automatically increases the values left of the decimal. I do not want that. Kindly assist.
@John
Try:
=INT(A2)+INT(A3)+(MOD(A2,SIGN(A2))+MOD(A3,SIGN(A3)))/10
Hi. Thanks for your post.
I need an formula to change location of decimal and integer digit in a number in excel, like 21.3 => 3.12.
HI
what about these two areas, a number 92.45 , id like to grab part of the numbers from both sides, cant seem to work out how to combine them, e.g. 92.45 I want .45 to be as 45 ( solved as above in a post ) however what about 245 where the first number and the decimals are only looked at . I don’t want he number 9 . also what about 81.7653 , I want to be able to grab only the last 3 digits of the decimal place, so it looks like 653?
any help on truncing this correctly would be good , thanks in advance.
Hi,
A1 cell is having integer part 12.00 and A2 Cell is having decimal part 0.34545. How can we concatenate in B1 Cell as 12.34545.
Please help me…
Thanks in Advance
Rgds
GNG
@GNG
=Int(A1)+A2