For values with at least one non-zero digit after a decimal place with no repeated series of digits detected, the function simply returns the total number of digits (ignoring trailing zeros) times -1. For example:
0.3 returns -1 because there is just one value after the decimal.
0.34567 returns -5 because there are no repeats up to the 5th decimal place.
0.1212125 returns -7 because there are no repeats (starting from the right) up to the 7th decimal place.
0.111117 returns -6 because there are no repeats (starting from the right) up to the 7th decimal place.
The function takes account of rounding up:
0.666 might be a truncated version of 2/3. Two and three each have 1 significant digit, so the function returns -1 (1 value after the decimal place).
0.667 also returns -1 because this might represent a rounding of 2/3 and it is customary to round digits up if the next digit would have been >5.
0.3334 returns -4 because it is inappropriate to round 3 up to 4 if the next digit would have been 5 or less.
Repeating series are accounted for. For example:
0.121212 returns -2 because "12" starts repeating after the second decimal place.
0.000678678678 returns -6 because "678" starts repeating after the 6th place.
0.678678678 returns -3.
0.678678679 also returns -3 because 678 could be rounded to 679 if the next digit were 6.
Note that you can set the minimum number of times a digit or series needs to be repeated to count as being repeated using the argument minReps. The default is 3, so digits or series of digits need to be repeated at least 3 times to count a repetition, but this can be changed:
0.1111 returns -1 using the default requirement for 3 repetitions but -4 if the number of minimum repetitions is 5 or more.
0.121212 returns -2 using the default requirement for 3 repetitions but -6 if the number of minimum repetitions is 4 or more.
Trailing zeros are ignored, so 0.12300 returns -3. When values do not have digits after a decimal place the location of the first non-zero digit from the right is returned as a positive integer. For example:
234 returns 1 because the first non-zero digit from the right is in the 1s place.
100 return 3 because the first non-zero digit from the right is in the 100s place.
70001 returns 1 because the first non-zero digit from the right is in the 1s place.
However, note a few oddities:
4E5 returns 6 but 4E50 probably will not return 51 because many computers have a hard time internally representing numbers that large.
4E-5 returns -5 but probably will not return -50 because many computers have a hard time internally representing numbers that small.
-100 and 100 return 3 and -0.12 and 0.12 return -2 because the negative sign is ignored.
0 returns 0.
NA and NaN returns NA.