Как разделить число по десятичной точке в Excel / Calc?

59701
hpy

У меня есть номер в электронной таблице, например, так: 28.686279

Когда я открыть этот лист в любом LibreOffice Calc или Microsoft Excel, есть формула функция, которая возвращает «целое число», то есть 28. Кроме того, есть формула, которая возвращает «дробная часть», т.е. 0.686279?

9

5 ответов на вопрос

14
DMA57361

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 in A1
  • A1-TRUNC(A1) to obtain the fractional part of the value in A1

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.

7
LiuYan 刘研

you can try FLOOR function, floor(A1,1) for integer part of A1, A1-floor(A1,1) for decimal part of A1.

Просто интересно, почему нет какой-либо функции FRAC (A1) для извлечения десятичной части? Кажется, это то, что люди делают довольно часто, верно? Alexis Wilke 10 лет назад 1
Как насчет негативов ... Robert Koritnik 7 лет назад 0
5
Brian554xx

Например, представьте, что А1 равен 167,583:
int(A1)даст 167 и
mod(A1,1)даст 0,583.

Вы понимаете, что `int (1.6) === 1` и` int (-1.6) === -2` ... Но `trunc (decimal; 0)` работает правильно для обоих. Robert Koritnik 7 лет назад 0
1
Alex Miller

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.

Это возвращает текст, а не число. fixer1234 9 лет назад 0
-3
Paul Fischer
=RIGHT(TEXT(ABS(A1)-INT(ABS(A1));",00");2) 

would'nt this be just perfect, and aesthetic, too?

Это возвращает текст, а не число. fixer1234 9 лет назад 0

Похожие вопросы