Unit Converter - Calculate the rounding precision of results based on the source (#498)

* precisely calculates the number of digits of the source and compute the number of significant digits of the result based on that.

* fix unit test

* Fix warning C4267

* Optimize how we calculate the number of digits in the integer part and don't trim the value when used by the currency converter

* modify GetNumberSignificantDigits

* fix CI error

* Access to wstring::npos from static calls

* Move UnitConverter static methods related to number to NumberFormattingUtils

* rename namespace

* Add comment and fix typo

* Move standard headers
This commit is contained in:
Rudy Huyn
2019-07-16 17:00:57 -07:00
committed by Pepe Rivera
parent 1b9d6b8fbe
commit 2ff7bb4089
9 changed files with 251 additions and 82 deletions

View File

@@ -279,9 +279,7 @@ namespace UnitConversionManager
double Convert(double value, ConversionData conversionData);
std::vector<std::tuple<std::wstring, Unit>> CalculateSuggested();
void ClearValues();
void TrimString(std::wstring& input);
void InitializeSelectedUnits();
std::wstring RoundSignificant(double num, int numSignificant);
Category StringToCategory(const std::wstring& w);
std::wstring CategoryToString(const Category& c, const wchar_t* delimiter);
std::wstring UnitToString(const Unit& u, const wchar_t* delimiter);