[PTRun][UnitConverter]Increase float number precision (#17758)

* [PT Run]  UnitConverter float number precision is not enough
Introduced rounding to significant digits, not to digits after decimal separator
Added conversion to string to fix last digit errors

* [PT Run]  UnitConverter float number precision is not enough
spell check fixes

* [PT Run]  UnitConverter float number precision is not enough
renamed test method to HandleNanometerToKilometer

* [PT Run]  UnitConverter float number precision is not enough
result copied to clipboard will not have unit, just a number
This commit is contained in:
lncubus
2022-04-19 12:20:12 +02:00
committed by GitHub
parent 38c538b0c5
commit da0aac2a18
4 changed files with 103 additions and 4 deletions

View File

@@ -62,7 +62,7 @@ namespace Community.PowerToys.Run.Plugin.UnitConverter
return new Result
{
ContextData = result,
Title = $"{result.ConvertedValue} {result.UnitName}",
Title = result.ToString(),
IcoPath = _icon_path,
Score = 300,
SubTitle = string.Format(CultureInfo.CurrentCulture, Properties.Resources.copy_to_clipboard, result.QuantityType),
@@ -73,7 +73,7 @@ namespace Community.PowerToys.Run.Plugin.UnitConverter
{
try
{
Clipboard.SetText(result.ConvertedValue.ToString(CultureInfo.CurrentCulture));
Clipboard.SetText(result.ConvertedValue.ToString(UnitConversionResult.Format, CultureInfo.CurrentCulture));
ret = true;
}
catch (ExternalException)
@@ -105,7 +105,7 @@ namespace Community.PowerToys.Run.Plugin.UnitConverter
{
try
{
Clipboard.SetText(result.ConvertedValue.ToString(CultureInfo.CurrentCulture));
Clipboard.SetText(result.ConvertedValue.ToString(UnitConversionResult.Format, CultureInfo.CurrentCulture));
ret = true;
}
catch (ExternalException)