Hi,

  I assume you want to know the digit count to the left of decimal point. 
If this is the case, then you may use  trunc(log10(max(1,trunc(abs(a)))))+1
for a numerical variable a.  Count 0.12 as having one digit to the left of
decimal point.

> trunc(log10(max(1,trunc(abs(-100000.99)))))+1
[1] 6
> trunc(log10(max(1,trunc(abs(0)))))+1
[1] 1
> trunc(log10(max(1,trunc(abs(9.999)))))+1
[1] 1
> trunc(log10(max(1,trunc(abs(19.999)))))+1
[1] 2
> trunc(log10(max(1,trunc(abs(-1999.999)))))+1
[1] 4



--
View this message in context: 
http://r.789695.n4.nabble.com/How-many-digits-are-there-in-left-of-dot-of-0-0001-tp4703842p4703847.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to