ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Lenght of a decimal part of a number. (https://www.excelbanter.com/excel-worksheet-functions/161111-lenght-decimal-part-number.html)

Yara

Lenght of a decimal part of a number.
 
Hi, I am doing some programming where I need to know the number of digits of
the only decimal part of a number. I ended up with the following equation:

In cell A1 I entered a decimal number.
In cell B1 I wrote the following : =LEN(A1-INT(A1))
this should give me the numbers of the decimal part.

Examples:
A1 B1
100 1
10.25 4
3.2 3
6.7 3
9.2 17 WHY? this my question.

Peo Sjoblom

Lenght of a decimal part of a number.
 
Try

=A5-INT(A5)

copy the result and paste special as values in a cell, now check what you
got


http://www.cpearson.com/excel/rounding.htm



--


Regards,


Peo Sjoblom


"Yara" wrote in message
...
Hi, I am doing some programming where I need to know the number of digits
of
the only decimal part of a number. I ended up with the following equation:

In cell A1 I entered a decimal number.
In cell B1 I wrote the following : =LEN(A1-INT(A1))
this should give me the numbers of the decimal part.

Examples:
A1 B1
100 1
10.25 4
3.2 3
6.7 3
9.2 17 WHY? this my question.




Harlan Grove

Lenght of a decimal part of a number.
 
Yara wrote...
Hi, I am doing some programming where I need to know the number of
digits of the only decimal part of a number. . . .

....
In cell B1 I wrote the following : =LEN(A1-INT(A1))

....

Use

=LEN(ABS(A1))-LEN(INT(ABS(A1)))-(A1<INT(A1))

instead.


cubbybear3

Lenght of a decimal part of a number.
 
or you could try this

=LEN(TEXT(A5-INT(A5),"#.#####"))-1


Rick Rothstein \(MVP - VB\)

Lenght of a decimal part of a number.
 
Hi, I am doing some programming where I need to know the number of
digits of the only decimal part of a number. . . .

...
In cell B1 I wrote the following : =LEN(A1-INT(A1))


Use

=LEN(ABS(A1))-LEN(INT(ABS(A1)))-(A1<INT(A1))

instead.


Here is a shorter formula which also appears to work...

=MAX(0,LEN(A1)-FIND(".",A1&"."))

Rick


All times are GMT +1. The time now is 10:58 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com