I noticed there is not (or I could not find) a function within commons-math
to count the number of significant figures in a number string. I wrote a
function to do it and want to make sure I'm not missing something within
commons-math before submitting a PR.

This feature is necessary when working with scientific/clinical data which
was reported with significant figures in mind, and for which calculation
results must respect the sigfig count. As far as I could tell there is no
Number implementation which correctly respects this. e.g.

"11000" has 2 significant figures,
"11000." has 5
".11000" has 5
"11000.0" has 6

Other points:
* BigDecimal.precision is not a substitute because it trailing whole zeros
are significant
* Floats, which can report scientific notation, are not a substitute when
calculations must be exact
* Ive also considered extending BigDecimal to support tracking and
enforcing sigfigs. This would still require the function to initially count
them.

Is this appropriate for a PR? Or have I missed an existing feature?

Dan

Reply via email to