How to separate number by its decimal point in Excel/Calc?
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Magic Ocean Looping
--
Chapters
00:00 How To Separate Number By Its Decimal Point In Excel/Calc?
00:30 Accepted Answer Score 17
01:33 Answer 2 Score 8
01:51 Answer 3 Score 5
02:11 Answer 4 Score 1
02:41 Thank you
--
Full question
https://superuser.com/questions/280929/h...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#microsoftexcel #worksheetfunction #libreofficecalc
#avk47
ACCEPTED ANSWER
Score 17
TRUNC()
is designed to remove the decimal part of any number immediately and without any modification to the non-decimal part.
So, as per LinYan's answer, you just need to use:
TRUNC(A1)
to obtain the integer part of the value inA1
A1-TRUNC(A1)
to obtain the fractional part of the value inA1
Unlike FLOOR()
, TRUNC()
works on both positive and negative numbers without requiring adjustment, and works in the same way in both Microsoft Excel and LibreOffice.
FLOOR()
requires the significance parameter to have the same sign as the number being processed (or else will throw an error), so the 1
at the end would have to be changed to -1
to process negative numbers, or you could insert SIGN()
and unnecessarily complicate the formula further.
And, in OpenOffice and LibreOffice, FLOOR()
also has an additional (compared to Excel) third "mode" parameter that changes the results that the function returns for negative numbers.
ANSWER 2
Score 8
you can try FLOOR
function, floor(A1,1)
for integer part of A1, A1-floor(A1,1)
for decimal part of A1.
ANSWER 3
Score 5
For example, imagine A1 is 167.583 :
int(A1)
would give 167 and
mod(A1,1)
would give 0.583 .
ANSWER 4
Score 1
Don't think there's a specific function to do this, however by nesting a couple you can.
Assuming you're trying to return the right-of-decimal value for cell A1, the formula would be:
=MID(A1,SEARCH(".",A1,1)+1,LEN(A1))
Effectively what you're doing here is using the MID function to return some number of characters starting at the decimal point. All 3 references to A1 need to be updated for each cell you're targeting for it to work correctly.