I will just describe a possible algorithm, assuming you start with a line.
- Starting on the left, find the decimal point. Count the numbers between them and either the
'E' or the end of the line. If there is no decimal point, the counter is zero. - Parse the value following
'E' and convert to an integer. If there is no 'E' , then zero. - Subtract the second from the first of two values; the maximum of this and zero is the result. So,
'2E-2' will have two decimal places, '1.2E+5' will not have any meaning, and pretty dumb '0.02E2' will not. - As a degenerate case, zero is likely to have zero decimal positions. As for infinity and any other special values, I don't have a clear opinion about whether these are zero decimal places or not.
source share