Skip to content

Commit

Permalink
commentary for trimOnlyZeros()
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Smith committed Apr 8, 2024
1 parent 8f4d9aa commit e6ae067
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions modules/c++/str/source/Manip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,16 @@ static std::string trimOnlyZeros(std::string strNumber, int precision)
strNumber = remove_leading_zeros(strNumber);
strNumber = remove_trailing_zeros(strNumber);

// TODO: Using `precission` might be be quite right. What I want to say is "if the last
// digit of a long decimal is preceeded by a bunch of zeros, then ignore that
// last digit (and the preceeding zeros)." Need to find a clear way to say
// both "nth" digit and "last" digit, as well as specifing exactly how many makes
// "a bunch" of zeros. For example, in "3.141500001", the "0.000000001" is
// likely just noise in many (even "most") cases. However, that may not be
// true for "3.14150009206" because even though there are three consequtive
// zeros, there are followed by two non-zero digits. ... or, the "92" are deemed
// to still be "interesting" digits.
//
// The "problem" with high values for `precision` is that we can get a bunch of trailing
// zeros e.g., "3.141500". Even "worse" is when there are a bunch of zeros and then
// a non-zero digit e.g., "3.141500001". In many cases, 0.000000001 is effectively
Expand Down

0 comments on commit e6ae067

Please sign in to comment.