theshoeshiner opened a new pull request, #1095: URL: https://github.com/apache/commons-lang/pull/1095
A util method in NumberUtils that counts the number of significant figures in a decimal strings of standard / exponential format. e.g.(101, 102.1, 5.1e2, 1.001, 0.2e4, etc...) This method counts the number of "significant figures" according to standard mathematical rules (details and references are in the javadoc). It must operate on a string because the rules themselves inherently depend on the string representation and not the underlying numeric value. The rules are well documented and widely accepted, aside from zero values, which are not usually covered by the conventions and the choice as to how to interpret is documented in the javadoc. My first instinct was that this belonged in commons-math or commons-numbers, as the concept of significant figures is usually necessary in scientific / mathematical fields, but thus far it doesnt seem to be a good fit. Decided Id create the PR here so that at least the implementation is out there for review and perhaps this discussion will find it a better home. I do feel like this is a valuable feature because any manipulation of numerical scientific data that needs to be accurate (e.g. clinical data) ultimately needs to respect significant figure counts. There are 7 basic rules that the method follows, #1-5 being the core sigfig rules that you'll find on most external sources, #6 to explain how zero values are handled, and #7 to explain how exponents are handled (or excluded, rather). The overall format of the string is validated, with IAEs thrown for invalid characters or formatting. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
