Files
PowerToys/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.UnitConverter/UnitConversionResult.cs
lncubus da0aac2a18 [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
2022-04-19 11:20:12 +01:00

37 lines
1.0 KiB
C#

// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using UnitsNet;
namespace Community.PowerToys.Run.Plugin.UnitConverter
{
public class UnitConversionResult
{
public static string Format { get; set; } = "g14";
public double ConvertedValue { get; }
public string UnitName { get; }
public QuantityType QuantityType { get; }
public UnitConversionResult(double convertedValue, string unitName, QuantityType quantityType)
{
ConvertedValue = convertedValue;
UnitName = unitName;
QuantityType = quantityType;
}
public string ToString(System.IFormatProvider provider = null)
{
if (provider == null)
{
provider = System.Globalization.CultureInfo.CurrentCulture;
}
return ConvertedValue.ToString(Format, provider) + " " + UnitName;
}
}
}