diff --git a/Common/UnitDefinitions/Power.json b/Common/UnitDefinitions/Power.json
index a6bf85e842..5dcd2a92aa 100644
--- a/Common/UnitDefinitions/Power.json
+++ b/Common/UnitDefinitions/Power.json
@@ -1,7 +1,6 @@
{
"Name": "Power",
"BaseUnit": "Watt",
- "ValueType": "decimal",
"XmlDocSummary": "In physics, power is the rate of doing work. It is equivalent to an amount of energy consumed per unit time.",
"BaseDimensions": {
"L": 2,
@@ -30,8 +29,8 @@
{
"SingularName": "MechanicalHorsepower",
"PluralName": "MechanicalHorsepower",
- "FromUnitToBaseFunc": "{x} * 745.69m",
- "FromBaseToUnitFunc": "{x} / 745.69m",
+ "FromUnitToBaseFunc": "{x} * 745.69",
+ "FromBaseToUnitFunc": "{x} / 745.69",
"Localization": [
{
"Culture": "en-US",
@@ -42,8 +41,8 @@
{
"SingularName": "MetricHorsepower",
"PluralName": "MetricHorsepower",
- "FromUnitToBaseFunc": "{x} * 735.49875m",
- "FromBaseToUnitFunc": "{x} / 735.49875m",
+ "FromUnitToBaseFunc": "{x} * 735.49875",
+ "FromBaseToUnitFunc": "{x} / 735.49875",
"Localization": [
{
"Culture": "en-US",
@@ -54,8 +53,8 @@
{
"SingularName": "ElectricalHorsepower",
"PluralName": "ElectricalHorsepower",
- "FromUnitToBaseFunc": "{x} * 746m",
- "FromBaseToUnitFunc": "{x} / 746m",
+ "FromUnitToBaseFunc": "{x} * 746",
+ "FromBaseToUnitFunc": "{x} / 746",
"Localization": [
{
"Culture": "en-US",
@@ -66,8 +65,8 @@
{
"SingularName": "BoilerHorsepower",
"PluralName": "BoilerHorsepower",
- "FromUnitToBaseFunc": "{x} * 9812.5m",
- "FromBaseToUnitFunc": "{x} / 9812.5m",
+ "FromUnitToBaseFunc": "{x} * 9812.5",
+ "FromBaseToUnitFunc": "{x} / 9812.5",
"Localization": [
{
"Culture": "en-US",
@@ -78,8 +77,8 @@
{
"SingularName": "HydraulicHorsepower",
"PluralName": "HydraulicHorsepower",
- "FromUnitToBaseFunc": "{x} * 745.69988145m",
- "FromBaseToUnitFunc": "{x} / 745.69988145m",
+ "FromUnitToBaseFunc": "{x} * 745.69988145",
+ "FromBaseToUnitFunc": "{x} / 745.69988145",
"Localization": [
{
"Culture": "en-US",
@@ -90,8 +89,8 @@
{
"SingularName": "BritishThermalUnitPerHour",
"PluralName": "BritishThermalUnitsPerHour",
- "FromUnitToBaseFunc": "{x} * 0.29307107017m",
- "FromBaseToUnitFunc": "{x} / 0.29307107017m",
+ "FromUnitToBaseFunc": "{x} * 0.29307107017",
+ "FromBaseToUnitFunc": "{x} / 0.29307107017",
"Prefixes": [ "Kilo", "Mega" ],
"Localization": [
{
@@ -103,8 +102,8 @@
{
"SingularName": "JoulePerHour",
"PluralName": "JoulesPerHour",
- "FromUnitToBaseFunc": "{x} / 3600m",
- "FromBaseToUnitFunc": "{x} * 3600m",
+ "FromUnitToBaseFunc": "{x} / 3600",
+ "FromBaseToUnitFunc": "{x} * 3600",
"Prefixes": [ "Milli", "Kilo", "Mega", "Giga" ],
"Localization": [
{
diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Power.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Power.g.cs
index e10cb3d208..e022e04860 100644
--- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Power.g.cs
+++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Power.g.cs
@@ -66,12 +66,12 @@ public Power(double value, PowerUnit unit)
///
/// Represents the largest possible value of Duration
///
- public static Power MaxValue { get; } = new Power(79228162514264337593543950335d, BaseUnit);
+ public static Power MaxValue { get; } = new Power(double.MaxValue, BaseUnit);
///
/// Represents the smallest possible value of Duration
///
- public static Power MinValue { get; } = new Power(-79228162514264337593543950335d, BaseUnit);
+ public static Power MinValue { get; } = new Power(double.MinValue, BaseUnit);
///
/// Gets an instance of this quantity with a value of 0 in the base unit Second.
@@ -409,26 +409,26 @@ private double GetValueInBaseUnit()
{
return Unit switch
{
- PowerUnit.BoilerHorsepower => _value * 9812.5d,
- PowerUnit.BritishThermalUnitPerHour => _value * 0.29307107017d,
+ PowerUnit.BoilerHorsepower => _value * 9812.5,
+ PowerUnit.BritishThermalUnitPerHour => _value * 0.29307107017,
PowerUnit.Decawatt => (_value) * 1e1d,
PowerUnit.Deciwatt => (_value) * 1e-1d,
- PowerUnit.ElectricalHorsepower => _value * 746d,
+ PowerUnit.ElectricalHorsepower => _value * 746,
PowerUnit.Femtowatt => (_value) * 1e-15d,
- PowerUnit.GigajoulePerHour => (_value / 3600d) * 1e9d,
+ PowerUnit.GigajoulePerHour => (_value / 3600) * 1e9d,
PowerUnit.Gigawatt => (_value) * 1e9d,
- PowerUnit.HydraulicHorsepower => _value * 745.69988145d,
- PowerUnit.JoulePerHour => _value / 3600d,
- PowerUnit.KilobritishThermalUnitPerHour => (_value * 0.29307107017d) * 1e3d,
- PowerUnit.KilojoulePerHour => (_value / 3600d) * 1e3d,
+ PowerUnit.HydraulicHorsepower => _value * 745.69988145,
+ PowerUnit.JoulePerHour => _value / 3600,
+ PowerUnit.KilobritishThermalUnitPerHour => (_value * 0.29307107017) * 1e3d,
+ PowerUnit.KilojoulePerHour => (_value / 3600) * 1e3d,
PowerUnit.Kilowatt => (_value) * 1e3d,
- PowerUnit.MechanicalHorsepower => _value * 745.69d,
- PowerUnit.MegabritishThermalUnitPerHour => (_value * 0.29307107017d) * 1e6d,
- PowerUnit.MegajoulePerHour => (_value / 3600d) * 1e6d,
+ PowerUnit.MechanicalHorsepower => _value * 745.69,
+ PowerUnit.MegabritishThermalUnitPerHour => (_value * 0.29307107017) * 1e6d,
+ PowerUnit.MegajoulePerHour => (_value / 3600) * 1e6d,
PowerUnit.Megawatt => (_value) * 1e6d,
- PowerUnit.MetricHorsepower => _value * 735.49875d,
+ PowerUnit.MetricHorsepower => _value * 735.49875,
PowerUnit.Microwatt => (_value) * 1e-6d,
- PowerUnit.MillijoulePerHour => (_value / 3600d) * 1e-3d,
+ PowerUnit.MillijoulePerHour => (_value / 3600) * 1e-3d,
PowerUnit.Milliwatt => (_value) * 1e-3d,
PowerUnit.Nanowatt => (_value) * 1e-9d,
PowerUnit.Petawatt => (_value) * 1e15d,
@@ -448,26 +448,26 @@ private double GetValueAs(PowerUnit unit)
return unit switch
{
- PowerUnit.BoilerHorsepower => baseUnitValue / 9812.5d,
- PowerUnit.BritishThermalUnitPerHour => baseUnitValue / 0.29307107017d,
+ PowerUnit.BoilerHorsepower => baseUnitValue / 9812.5,
+ PowerUnit.BritishThermalUnitPerHour => baseUnitValue / 0.29307107017,
PowerUnit.Decawatt => (baseUnitValue) / 1e1d,
PowerUnit.Deciwatt => (baseUnitValue) / 1e-1d,
- PowerUnit.ElectricalHorsepower => baseUnitValue / 746d,
+ PowerUnit.ElectricalHorsepower => baseUnitValue / 746,
PowerUnit.Femtowatt => (baseUnitValue) / 1e-15d,
- PowerUnit.GigajoulePerHour => (baseUnitValue * 3600d) / 1e9d,
+ PowerUnit.GigajoulePerHour => (baseUnitValue * 3600) / 1e9d,
PowerUnit.Gigawatt => (baseUnitValue) / 1e9d,
- PowerUnit.HydraulicHorsepower => baseUnitValue / 745.69988145d,
- PowerUnit.JoulePerHour => baseUnitValue * 3600d,
- PowerUnit.KilobritishThermalUnitPerHour => (baseUnitValue / 0.29307107017d) / 1e3d,
- PowerUnit.KilojoulePerHour => (baseUnitValue * 3600d) / 1e3d,
+ PowerUnit.HydraulicHorsepower => baseUnitValue / 745.69988145,
+ PowerUnit.JoulePerHour => baseUnitValue * 3600,
+ PowerUnit.KilobritishThermalUnitPerHour => (baseUnitValue / 0.29307107017) / 1e3d,
+ PowerUnit.KilojoulePerHour => (baseUnitValue * 3600) / 1e3d,
PowerUnit.Kilowatt => (baseUnitValue) / 1e3d,
- PowerUnit.MechanicalHorsepower => baseUnitValue / 745.69d,
- PowerUnit.MegabritishThermalUnitPerHour => (baseUnitValue / 0.29307107017d) / 1e6d,
- PowerUnit.MegajoulePerHour => (baseUnitValue * 3600d) / 1e6d,
+ PowerUnit.MechanicalHorsepower => baseUnitValue / 745.69,
+ PowerUnit.MegabritishThermalUnitPerHour => (baseUnitValue / 0.29307107017) / 1e6d,
+ PowerUnit.MegajoulePerHour => (baseUnitValue * 3600) / 1e6d,
PowerUnit.Megawatt => (baseUnitValue) / 1e6d,
- PowerUnit.MetricHorsepower => baseUnitValue / 735.49875d,
+ PowerUnit.MetricHorsepower => baseUnitValue / 735.49875,
PowerUnit.Microwatt => (baseUnitValue) / 1e-6d,
- PowerUnit.MillijoulePerHour => (baseUnitValue * 3600d) / 1e-3d,
+ PowerUnit.MillijoulePerHour => (baseUnitValue * 3600) / 1e-3d,
PowerUnit.Milliwatt => (baseUnitValue) / 1e-3d,
PowerUnit.Nanowatt => (baseUnitValue) / 1e-9d,
PowerUnit.Petawatt => (baseUnitValue) / 1e15d,
diff --git a/UnitsNet.Serialization.JsonNet.Tests/UnitsNetBaseJsonConverterTest.cs b/UnitsNet.Serialization.JsonNet.Tests/UnitsNetBaseJsonConverterTest.cs
index f4e42ab480..8119df0815 100644
--- a/UnitsNet.Serialization.JsonNet.Tests/UnitsNetBaseJsonConverterTest.cs
+++ b/UnitsNet.Serialization.JsonNet.Tests/UnitsNetBaseJsonConverterTest.cs
@@ -33,10 +33,10 @@ public void UnitsNetBaseJsonConverter_ConvertIQuantity_works_with_double_type()
[Fact]
public void UnitsNetBaseJsonConverter_ConvertIQuantity_works_with_decimal_type()
{
- var result = _sut.Test_ConvertDecimalIQuantity(Power.FromWatts(10.2365m));
+ var result = _sut.Test_ConvertDecimalIQuantity(Information.FromBits(64m));
- Assert.Equal("PowerUnit.Watt", result.Unit);
- Assert.Equal(10.2365m, result.Value);
+ Assert.Equal("InformationUnit.Bit", result.Unit);
+ Assert.Equal(64m, result.Value);
}
[Fact]
@@ -54,8 +54,7 @@ public void UnitsNetBaseJsonConverter_ConvertValueUnit_works_as_expected()
Assert.NotNull(result);
Assert.IsType(result);
- Assert.True(Power.FromWatts(10.2365m).Equals((Power)result, 1E-5m, ComparisonType.Absolute));
-
+ Assert.True(Power.FromWatts(10.2365).Equals((Power)result, 1e-5, ComparisonType.Absolute));
}
[Fact]
diff --git a/UnitsNet.Serialization.JsonNet.Tests/UnitsNetIComparableJsonConverterTest.cs b/UnitsNet.Serialization.JsonNet.Tests/UnitsNetIComparableJsonConverterTest.cs
index a9919d4cdc..ccbbc220e1 100644
--- a/UnitsNet.Serialization.JsonNet.Tests/UnitsNetIComparableJsonConverterTest.cs
+++ b/UnitsNet.Serialization.JsonNet.Tests/UnitsNetIComparableJsonConverterTest.cs
@@ -119,7 +119,7 @@ public void UnitsNetIComparableJsonConverter_ReadJson_works_as_expected()
Assert.NotNull(result);
Assert.IsType(result);
- Assert.Equal(120M, ((Power)result).Watts);
+ Assert.Equal(120, ((Power)result).Watts);
}
}
}
diff --git a/UnitsNet.Serialization.JsonNet.Tests/UnitsNetIQuantityJsonConverterTest.cs b/UnitsNet.Serialization.JsonNet.Tests/UnitsNetIQuantityJsonConverterTest.cs
index 8ed7de7c29..aa0106de94 100644
--- a/UnitsNet.Serialization.JsonNet.Tests/UnitsNetIQuantityJsonConverterTest.cs
+++ b/UnitsNet.Serialization.JsonNet.Tests/UnitsNetIQuantityJsonConverterTest.cs
@@ -78,10 +78,10 @@ public void UnitsNetIQuantityJsonConverter_WriteJson_works_with_decimal_quantity
using (var stringWriter = new StringWriter(result))
using(var writer = new JsonTextWriter(stringWriter))
{
- _sut.WriteJson(writer, Power.FromWatts(value), JsonSerializer.CreateDefault());
+ _sut.WriteJson(writer, Information.FromBits(value), JsonSerializer.CreateDefault());
}
- Assert.Equal($"{{\"Unit\":\"PowerUnit.Watt\",\"Value\":{expectedValue},\"ValueString\":\"{expectedValueString}\",\"ValueType\":\"decimal\"}}",
+ Assert.Equal($"{{\"Unit\":\"InformationUnit.Bit\",\"Value\":{expectedValue},\"ValueString\":\"{expectedValueString}\",\"ValueType\":\"decimal\"}}",
result.ToString());
}
@@ -135,7 +135,7 @@ public void UnitsNetIQuantityJsonConverter_ReadJson_works_as_expected()
Assert.NotNull(result);
Assert.IsType(result);
- Assert.Equal(10.3654M, ((Power)result).Watts);
+ Assert.Equal(10.3654, ((Power)result).Watts);
}
}
}
diff --git a/UnitsNet.Tests/CustomCode/IQuantityTests.cs b/UnitsNet.Tests/CustomCode/IQuantityTests.cs
index 710cb4df17..abae93ba96 100644
--- a/UnitsNet.Tests/CustomCode/IQuantityTests.cs
+++ b/UnitsNet.Tests/CustomCode/IQuantityTests.cs
@@ -93,12 +93,5 @@ public void IQuantityTUnitDecimal_AsEnum_ReturnsDecimal()
IQuantity decimalQuantity = Information.FromKilobytes(1234.5);
Assert.IsType(decimalQuantity.As(InformationUnit.Byte));
}
-
- [Fact]
- public void IQuantityTUnitDecimal_AsUnitSystem_ReturnsDecimal()
- {
- IQuantity decimalQuantity = Power.FromMegawatts(1234.5);
- Assert.IsType(decimalQuantity.As(UnitSystem.SI));
- }
}
}
diff --git a/UnitsNet.Tests/CustomCode/MassFlowTests.cs b/UnitsNet.Tests/CustomCode/MassFlowTests.cs
index 5c64e0b394..3c0ca9836b 100644
--- a/UnitsNet.Tests/CustomCode/MassFlowTests.cs
+++ b/UnitsNet.Tests/CustomCode/MassFlowTests.cs
@@ -108,7 +108,7 @@ public void TimeSpanTimesMassFlowEqualsMass()
public void MassFlowDividedByBrakeSpecificFuelConsumptionEqualsPower()
{
Power power = MassFlow.FromTonnesPerDay(20) / BrakeSpecificFuelConsumption.FromGramsPerKiloWattHour(180.0);
- AssertEx.EqualTolerance(20.0m / 24.0m * 1e6m / 180.0m, power.Kilowatts, 1E-11m);
+ AssertEx.EqualTolerance(20.0 / 24.0 * 1e6 / 180.0, power.Kilowatts, 1e-11);
}
[Fact]
diff --git a/UnitsNet.Tests/CustomCode/PowerRatioTests.cs b/UnitsNet.Tests/CustomCode/PowerRatioTests.cs
index ae0ebf6fad..adb1ee96fc 100644
--- a/UnitsNet.Tests/CustomCode/PowerRatioTests.cs
+++ b/UnitsNet.Tests/CustomCode/PowerRatioTests.cs
@@ -55,8 +55,8 @@ public void ExpectPowerConvertedCorrectly(double power, double expected)
public void ExpectPowerRatioConvertedCorrectly(double powerRatio, double expected)
{
PowerRatio pr = PowerRatio.FromDecibelWatts(powerRatio);
- decimal actual = pr.ToPower().Watts;
- Assert.Equal((decimal)expected, actual);
+ var actual = pr.ToPower().Watts;
+ Assert.Equal(expected, actual);
}
// http://www.maximintegrated.com/en/app-notes/index.mvp/id/808
diff --git a/UnitsNet.Tests/CustomCode/PowerTests.cs b/UnitsNet.Tests/CustomCode/PowerTests.cs
index 99ebcec1cc..1b80aad460 100644
--- a/UnitsNet.Tests/CustomCode/PowerTests.cs
+++ b/UnitsNet.Tests/CustomCode/PowerTests.cs
@@ -9,57 +9,58 @@ namespace UnitsNet.Tests
public class PowerTests : PowerTestsBase
{
protected override bool SupportsSIUnitSystem => true;
- protected override decimal FemtowattsInOneWatt => 1e15m;
- protected override decimal GigajoulesPerHourInOneWatt => 3600e-9m;
+ protected override double FemtowattsInOneWatt => 1e15;
- protected override decimal PicowattsInOneWatt => 1e12m;
+ protected override double GigajoulesPerHourInOneWatt => 3600e-9;
- protected override decimal NanowattsInOneWatt => 1e9m;
+ protected override double PicowattsInOneWatt => 1e12;
- protected override decimal MicrowattsInOneWatt => 1e6m;
+ protected override double NanowattsInOneWatt => 1e9;
- protected override decimal MillijoulesPerHourInOneWatt => 3600e3m;
+ protected override double MicrowattsInOneWatt => 1e6;
- protected override decimal MilliwattsInOneWatt => 1e3m;
+ protected override double MillijoulesPerHourInOneWatt => 3600e3;
- protected override decimal DeciwattsInOneWatt => 1e1m;
+ protected override double MilliwattsInOneWatt => 1e3;
- protected override decimal WattsInOneWatt => 1;
+ protected override double DeciwattsInOneWatt => 1e1;
- protected override decimal DecawattsInOneWatt => 1e-1m;
+ protected override double WattsInOneWatt => 1;
- protected override decimal KilojoulesPerHourInOneWatt => 3600e-3m;
+ protected override double DecawattsInOneWatt => 1e-1;
- protected override decimal KilowattsInOneWatt => 1e-3m;
+ protected override double KilojoulesPerHourInOneWatt => 3600e-3;
- protected override decimal MegajoulesPerHourInOneWatt => 3600e-6m;
+ protected override double KilowattsInOneWatt => 1e-3;
- protected override decimal MegawattsInOneWatt => 1e-6m;
+ protected override double MegajoulesPerHourInOneWatt => 3600e-6;
- protected override decimal GigawattsInOneWatt => 1e-9m;
+ protected override double MegawattsInOneWatt => 1e-6;
- protected override decimal TerawattsInOneWatt => 1e-12m;
+ protected override double GigawattsInOneWatt => 1e-9;
- protected override decimal PetawattsInOneWatt => 1e-15m;
+ protected override double TerawattsInOneWatt => 1e-12;
- protected override decimal JoulesPerHourInOneWatt => 3600;
+ protected override double PetawattsInOneWatt => 1e-15;
- protected override decimal KilobritishThermalUnitsPerHourInOneWatt => 3.412141633e-3m;
+ protected override double JoulesPerHourInOneWatt => 3600;
- protected override decimal BoilerHorsepowerInOneWatt => 1.0191082802547770700636942675159e-4m;
+ protected override double KilobritishThermalUnitsPerHourInOneWatt => 3.412141633e-3;
- protected override decimal MegabritishThermalUnitsPerHourInOneWatt => 3.412141633e-6m;
+ protected override double BoilerHorsepowerInOneWatt => 1.0191082802547770700636942675159e-4;
- protected override decimal BritishThermalUnitsPerHourInOneWatt => 3.412141633m;
+ protected override double MegabritishThermalUnitsPerHourInOneWatt => 3.412141633e-6;
- protected override decimal ElectricalHorsepowerInOneWatt => 0.00134048257372654155495978552279m;
+ protected override double BritishThermalUnitsPerHourInOneWatt => 3.412141633;
- protected override decimal HydraulicHorsepowerInOneWatt => 0.00134102207184949258114167291719m;
+ protected override double ElectricalHorsepowerInOneWatt => 0.00134048257372654155495978552279;
- protected override decimal MechanicalHorsepowerInOneWatt => 0.00134103984229371454625916935992m;
+ protected override double HydraulicHorsepowerInOneWatt => 0.00134102207184949258114167291719;
- protected override decimal MetricHorsepowerInOneWatt => 0.00135962161730390432342679032425m;
+ protected override double MechanicalHorsepowerInOneWatt => 0.00134103984229371454625916935992;
+
+ protected override double MetricHorsepowerInOneWatt => 0.00135962161730390432342679032425;
[Fact]
public void DurationTimesPowerEqualsEnergy()
diff --git a/UnitsNet.Tests/CustomCode/SpecificEnergyTests.cs b/UnitsNet.Tests/CustomCode/SpecificEnergyTests.cs
index 89f34675d7..27b5c448ea 100644
--- a/UnitsNet.Tests/CustomCode/SpecificEnergyTests.cs
+++ b/UnitsNet.Tests/CustomCode/SpecificEnergyTests.cs
@@ -71,7 +71,7 @@ public void DoubleDividedBySpecificEnergyEqualsBrakeSpecificFuelConsumption()
public void SpecificEnergyTimesMassFlowEqualsPower()
{
Power power = SpecificEnergy.FromJoulesPerKilogram(10.0) * MassFlow.FromKilogramsPerSecond(20.0);
- Assert.Equal(200m, power.Watts);
+ Assert.Equal(200, power.Watts);
}
[Fact]
diff --git a/UnitsNet.Tests/DecimalOverloadTests.cs b/UnitsNet.Tests/DecimalOverloadTests.cs
deleted file mode 100644
index 6b9842d0aa..0000000000
--- a/UnitsNet.Tests/DecimalOverloadTests.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-// Licensed under MIT No Attribution, see LICENSE file at the root.
-// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet.
-
-using Xunit;
-
-namespace UnitsNet.Tests
-{
- public class DecimalOverloadTests
- {
- [Fact]
- public static void CreatingQuantityWithDoubleBackingFieldFromDecimalReturnsCorrectValue()
- {
- Acceleration acceleration = Acceleration.FromMetersPerSecondSquared(1m);
- Assert.Equal(1.0, acceleration.MetersPerSecondSquared);
- }
-
- [Fact]
- public static void CreatingQuantityWithDecimalBackingFieldFromDecimalReturnsCorrectValue()
- {
- Power power = Power.FromWatts(1m);
- Assert.Equal(1.0m, power.Watts);
- }
- }
-}
diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs
index fc2e98998d..e676cac6c0 100644
--- a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs
+++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs
@@ -38,63 +38,63 @@ namespace UnitsNet.Tests
// ReSharper disable once PartialTypeWithSinglePart
public abstract partial class PowerTestsBase : QuantityTestsBase
{
- protected abstract decimal BoilerHorsepowerInOneWatt { get; }
- protected abstract decimal BritishThermalUnitsPerHourInOneWatt { get; }
- protected abstract decimal DecawattsInOneWatt { get; }
- protected abstract decimal DeciwattsInOneWatt { get; }
- protected abstract decimal ElectricalHorsepowerInOneWatt { get; }
- protected abstract decimal FemtowattsInOneWatt { get; }
- protected abstract decimal GigajoulesPerHourInOneWatt { get; }
- protected abstract decimal GigawattsInOneWatt { get; }
- protected abstract decimal HydraulicHorsepowerInOneWatt { get; }
- protected abstract decimal JoulesPerHourInOneWatt { get; }
- protected abstract decimal KilobritishThermalUnitsPerHourInOneWatt { get; }
- protected abstract decimal KilojoulesPerHourInOneWatt { get; }
- protected abstract decimal KilowattsInOneWatt { get; }
- protected abstract decimal MechanicalHorsepowerInOneWatt { get; }
- protected abstract decimal MegabritishThermalUnitsPerHourInOneWatt { get; }
- protected abstract decimal MegajoulesPerHourInOneWatt { get; }
- protected abstract decimal MegawattsInOneWatt { get; }
- protected abstract decimal MetricHorsepowerInOneWatt { get; }
- protected abstract decimal MicrowattsInOneWatt { get; }
- protected abstract decimal MillijoulesPerHourInOneWatt { get; }
- protected abstract decimal MilliwattsInOneWatt { get; }
- protected abstract decimal NanowattsInOneWatt { get; }
- protected abstract decimal PetawattsInOneWatt { get; }
- protected abstract decimal PicowattsInOneWatt { get; }
- protected abstract decimal TerawattsInOneWatt { get; }
- protected abstract decimal WattsInOneWatt { get; }
+ protected abstract double BoilerHorsepowerInOneWatt { get; }
+ protected abstract double BritishThermalUnitsPerHourInOneWatt { get; }
+ protected abstract double DecawattsInOneWatt { get; }
+ protected abstract double DeciwattsInOneWatt { get; }
+ protected abstract double ElectricalHorsepowerInOneWatt { get; }
+ protected abstract double FemtowattsInOneWatt { get; }
+ protected abstract double GigajoulesPerHourInOneWatt { get; }
+ protected abstract double GigawattsInOneWatt { get; }
+ protected abstract double HydraulicHorsepowerInOneWatt { get; }
+ protected abstract double JoulesPerHourInOneWatt { get; }
+ protected abstract double KilobritishThermalUnitsPerHourInOneWatt { get; }
+ protected abstract double KilojoulesPerHourInOneWatt { get; }
+ protected abstract double KilowattsInOneWatt { get; }
+ protected abstract double MechanicalHorsepowerInOneWatt { get; }
+ protected abstract double MegabritishThermalUnitsPerHourInOneWatt { get; }
+ protected abstract double MegajoulesPerHourInOneWatt { get; }
+ protected abstract double MegawattsInOneWatt { get; }
+ protected abstract double MetricHorsepowerInOneWatt { get; }
+ protected abstract double MicrowattsInOneWatt { get; }
+ protected abstract double MillijoulesPerHourInOneWatt { get; }
+ protected abstract double MilliwattsInOneWatt { get; }
+ protected abstract double NanowattsInOneWatt { get; }
+ protected abstract double PetawattsInOneWatt { get; }
+ protected abstract double PicowattsInOneWatt { get; }
+ protected abstract double TerawattsInOneWatt { get; }
+ protected abstract double WattsInOneWatt { get; }
// ReSharper disable VirtualMemberNeverOverriden.Global
- protected virtual decimal BoilerHorsepowerTolerance { get { return 1e-9m; } }
- protected virtual decimal BritishThermalUnitsPerHourTolerance { get { return 1e-9m; } }
- protected virtual decimal DecawattsTolerance { get { return 1e-9m; } }
- protected virtual decimal DeciwattsTolerance { get { return 1e-9m; } }
- protected virtual decimal ElectricalHorsepowerTolerance { get { return 1e-9m; } }
- protected virtual decimal FemtowattsTolerance { get { return 1e-9m; } }
- protected virtual decimal GigajoulesPerHourTolerance { get { return 1e-9m; } }
- protected virtual decimal GigawattsTolerance { get { return 1e-9m; } }
- protected virtual decimal HydraulicHorsepowerTolerance { get { return 1e-9m; } }
- protected virtual decimal JoulesPerHourTolerance { get { return 1e-9m; } }
- protected virtual decimal KilobritishThermalUnitsPerHourTolerance { get { return 1e-9m; } }
- protected virtual decimal KilojoulesPerHourTolerance { get { return 1e-9m; } }
- protected virtual decimal KilowattsTolerance { get { return 1e-9m; } }
- protected virtual decimal MechanicalHorsepowerTolerance { get { return 1e-9m; } }
- protected virtual decimal MegabritishThermalUnitsPerHourTolerance { get { return 1e-9m; } }
- protected virtual decimal MegajoulesPerHourTolerance { get { return 1e-9m; } }
- protected virtual decimal MegawattsTolerance { get { return 1e-9m; } }
- protected virtual decimal MetricHorsepowerTolerance { get { return 1e-9m; } }
- protected virtual decimal MicrowattsTolerance { get { return 1e-9m; } }
- protected virtual decimal MillijoulesPerHourTolerance { get { return 1e-9m; } }
- protected virtual decimal MilliwattsTolerance { get { return 1e-9m; } }
- protected virtual decimal NanowattsTolerance { get { return 1e-9m; } }
- protected virtual decimal PetawattsTolerance { get { return 1e-9m; } }
- protected virtual decimal PicowattsTolerance { get { return 1e-9m; } }
- protected virtual decimal TerawattsTolerance { get { return 1e-9m; } }
- protected virtual decimal WattsTolerance { get { return 1e-9m; } }
+ protected virtual double BoilerHorsepowerTolerance { get { return 1e-5; } }
+ protected virtual double BritishThermalUnitsPerHourTolerance { get { return 1e-5; } }
+ protected virtual double DecawattsTolerance { get { return 1e-5; } }
+ protected virtual double DeciwattsTolerance { get { return 1e-5; } }
+ protected virtual double ElectricalHorsepowerTolerance { get { return 1e-5; } }
+ protected virtual double FemtowattsTolerance { get { return 1e-5; } }
+ protected virtual double GigajoulesPerHourTolerance { get { return 1e-5; } }
+ protected virtual double GigawattsTolerance { get { return 1e-5; } }
+ protected virtual double HydraulicHorsepowerTolerance { get { return 1e-5; } }
+ protected virtual double JoulesPerHourTolerance { get { return 1e-5; } }
+ protected virtual double KilobritishThermalUnitsPerHourTolerance { get { return 1e-5; } }
+ protected virtual double KilojoulesPerHourTolerance { get { return 1e-5; } }
+ protected virtual double KilowattsTolerance { get { return 1e-5; } }
+ protected virtual double MechanicalHorsepowerTolerance { get { return 1e-5; } }
+ protected virtual double MegabritishThermalUnitsPerHourTolerance { get { return 1e-5; } }
+ protected virtual double MegajoulesPerHourTolerance { get { return 1e-5; } }
+ protected virtual double MegawattsTolerance { get { return 1e-5; } }
+ protected virtual double MetricHorsepowerTolerance { get { return 1e-5; } }
+ protected virtual double MicrowattsTolerance { get { return 1e-5; } }
+ protected virtual double MillijoulesPerHourTolerance { get { return 1e-5; } }
+ protected virtual double MilliwattsTolerance { get { return 1e-5; } }
+ protected virtual double NanowattsTolerance { get { return 1e-5; } }
+ protected virtual double PetawattsTolerance { get { return 1e-5; } }
+ protected virtual double PicowattsTolerance { get { return 1e-5; } }
+ protected virtual double TerawattsTolerance { get { return 1e-5; } }
+ protected virtual double WattsTolerance { get { return 1e-5; } }
// ReSharper restore VirtualMemberNeverOverriden.Global
- protected (decimal UnitsInBaseUnit, decimal Tolerence) GetConversionFactor(PowerUnit unit)
+ protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(PowerUnit unit)
{
return unit switch
{
@@ -163,10 +163,27 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit()
{
var quantity = new Power();
Assert.Equal(0, quantity.Value);
- Assert.Equal(0m, ((IValueQuantity)quantity).Value);
Assert.Equal(PowerUnit.Watt, quantity.Unit);
}
+ [Fact]
+ public void Ctor_WithInfinityValue_DoNotThrowsArgumentException()
+ {
+ var exception1 = Record.Exception(() => new Power(double.PositiveInfinity, PowerUnit.Watt));
+ var exception2 = Record.Exception(() => new Power(double.NegativeInfinity, PowerUnit.Watt));
+
+ Assert.Null(exception1);
+ Assert.Null(exception2);
+ }
+
+ [Fact]
+ public void Ctor_WithNaNValue_DoNotThrowsArgumentException()
+ {
+ var exception = Record.Exception(() => new Power(double.NaN, PowerUnit.Watt));
+
+ Assert.Null(exception);
+ }
+
[Fact]
public void Ctor_NullAsUnitSystem_ThrowsArgumentNullException()
{
@@ -343,6 +360,24 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit()
}
+ [Fact]
+ public void FromWatts_WithInfinityValue_DoNotThrowsArgumentException()
+ {
+ var exception1 = Record.Exception(() => Power.FromWatts(double.PositiveInfinity));
+ var exception2 = Record.Exception(() => Power.FromWatts(double.NegativeInfinity));
+
+ Assert.Null(exception1);
+ Assert.Null(exception2);
+ }
+
+ [Fact]
+ public void FromWatts_WithNanValue_DoNotThrowsArgumentException()
+ {
+ var exception = Record.Exception(() => Power.FromWatts(double.NaN));
+
+ Assert.Null(exception);
+ }
+
[Fact]
public void As()
{
@@ -1174,7 +1209,7 @@ public void CompareToThrowsOnNull()
[InlineData(1, PowerUnit.Watt, 2, PowerUnit.Watt, false)] // Different value.
[InlineData(2, PowerUnit.Watt, 1, PowerUnit.BoilerHorsepower, false)] // Different value and unit.
[InlineData(1, PowerUnit.Watt, 1, PowerUnit.BoilerHorsepower, false)] // Different unit.
- public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(decimal valueA, PowerUnit unitA, decimal valueB, PowerUnit unitB, bool expectEqual)
+ public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, PowerUnit unitA, double valueB, PowerUnit unitB, bool expectEqual)
{
var a = new Power(valueA, unitA);
var b = new Power(valueB, unitB);
@@ -1335,10 +1370,10 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul
try
{
CultureInfo.CurrentCulture = CultureInfo.InvariantCulture;
- Assert.Equal("0.1 W", new Power(0.123456m, PowerUnit.Watt).ToString("s1"));
- Assert.Equal("0.12 W", new Power(0.123456m, PowerUnit.Watt).ToString("s2"));
- Assert.Equal("0.123 W", new Power(0.123456m, PowerUnit.Watt).ToString("s3"));
- Assert.Equal("0.1235 W", new Power(0.123456m, PowerUnit.Watt).ToString("s4"));
+ Assert.Equal("0.1 W", new Power(0.123456, PowerUnit.Watt).ToString("s1"));
+ Assert.Equal("0.12 W", new Power(0.123456, PowerUnit.Watt).ToString("s2"));
+ Assert.Equal("0.123 W", new Power(0.123456, PowerUnit.Watt).ToString("s3"));
+ Assert.Equal("0.1235 W", new Power(0.123456, PowerUnit.Watt).ToString("s4"));
}
finally
{
@@ -1350,10 +1385,10 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul
public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixForGivenCulture()
{
var culture = CultureInfo.InvariantCulture;
- Assert.Equal("0.1 W", new Power(0.123456m, PowerUnit.Watt).ToString("s1", culture));
- Assert.Equal("0.12 W", new Power(0.123456m, PowerUnit.Watt).ToString("s2", culture));
- Assert.Equal("0.123 W", new Power(0.123456m, PowerUnit.Watt).ToString("s3", culture));
- Assert.Equal("0.1235 W", new Power(0.123456m, PowerUnit.Watt).ToString("s4", culture));
+ Assert.Equal("0.1 W", new Power(0.123456, PowerUnit.Watt).ToString("s1", culture));
+ Assert.Equal("0.12 W", new Power(0.123456, PowerUnit.Watt).ToString("s2", culture));
+ Assert.Equal("0.123 W", new Power(0.123456, PowerUnit.Watt).ToString("s3", culture));
+ Assert.Equal("0.1235 W", new Power(0.123456, PowerUnit.Watt).ToString("s4", culture));
}
[Theory]
diff --git a/UnitsNet.Tests/IValueQuantityTests.cs b/UnitsNet.Tests/IValueQuantityTests.cs
index a6379e33af..a0a8a1b318 100644
--- a/UnitsNet.Tests/IValueQuantityTests.cs
+++ b/UnitsNet.Tests/IValueQuantityTests.cs
@@ -44,13 +44,6 @@ public void IValueQuantityTDecimal_AsEnum_ReturnsDecimal()
Assert.IsType(decimalQuantity.As(InformationUnit.Byte));
}
- [Fact]
- public void IValueQuantityTDecimal_AsUnitSystem_ReturnsDecimal()
- {
- IValueQuantity decimalQuantity = Power.FromMegawatts(1234.5);
- Assert.IsType(decimalQuantity.As(UnitSystem.SI));
- }
-
[Fact]
public void IValueQuantityTDouble_ToUnitEnum_ReturnsIValueQuantityTDouble()
{
@@ -71,12 +64,5 @@ public void IValueQuantityTDecimal_ToUnitEnum_ReturnsIValueQuantityTDecimal()
IValueQuantity decimalQuantity = Information.FromKilobytes(1234.5);
Assert.IsAssignableFrom>(decimalQuantity.ToUnit(InformationUnit.Bit));
}
-
- [Fact]
- public void IValueQuantityTDecimal_ToUnitUnitSystem_ReturnsIValueQuantityTDecimal()
- {
- IValueQuantity decimalQuantity = Power.FromWatts(1234.5);
- Assert.IsAssignableFrom>(decimalQuantity.ToUnit(UnitSystem.SI));
- }
}
}
diff --git a/UnitsNet.Tests/IntOverloadTests.cs b/UnitsNet.Tests/IntOverloadTests.cs
deleted file mode 100644
index 9d059dcc46..0000000000
--- a/UnitsNet.Tests/IntOverloadTests.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-// Licensed under MIT No Attribution, see LICENSE file at the root.
-// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet.
-
-using Xunit;
-
-namespace UnitsNet.Tests
-{
- public class IntOverloadTests
- {
- [Fact]
- public static void CreatingQuantityWithDoubleBackingFieldFromIntReturnsCorrectValue()
- {
- Acceleration acceleration = Acceleration.FromMetersPerSecondSquared(1);
- Assert.Equal(1.0, acceleration.MetersPerSecondSquared);
- }
-
- [Fact]
- public static void CreatingQuantityWithIntBackingFieldFromIntReturnsCorrectValue()
- {
- Power power = Power.FromWatts(1);
- Assert.Equal(1.0m, power.Watts);
- }
- }
-}
diff --git a/UnitsNet.Tests/LongOverloadTests.cs b/UnitsNet.Tests/LongOverloadTests.cs
deleted file mode 100644
index ba5c00a538..0000000000
--- a/UnitsNet.Tests/LongOverloadTests.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-// Licensed under MIT No Attribution, see LICENSE file at the root.
-// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet.
-
-using Xunit;
-
-namespace UnitsNet.Tests
-{
- public class LongOverloadTests
- {
- [Fact]
- public static void CreatingQuantityWithDoubleBackingFieldFromLongReturnsCorrectValue()
- {
- Acceleration acceleration = Acceleration.FromMetersPerSecondSquared(1L);
- Assert.Equal(1.0, acceleration.MetersPerSecondSquared);
- }
-
- [Fact]
- public static void CreatingQuantityWithLongBackingFieldFromLongReturnsCorrectValue()
- {
- Power power = Power.FromWatts(1L);
- Assert.Equal(1.0m, power.Watts);
- }
- }
-}
diff --git a/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs b/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs
index 090b96d8dc..e882651b01 100644
--- a/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs
@@ -478,7 +478,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Brake
/// Get from * .
public static MassFlow operator *(BrakeSpecificFuelConsumption brakeSpecificFuelConsumption, Power power)
{
- return MassFlow.FromKilogramsPerSecond(brakeSpecificFuelConsumption.KilogramsPerJoule * (double)power.Watts);
+ return MassFlow.FromKilogramsPerSecond(brakeSpecificFuelConsumption.KilogramsPerJoule * power.Watts);
}
/// Get from / .
diff --git a/UnitsNet/GeneratedCode/Quantities/Duration.g.cs b/UnitsNet/GeneratedCode/Quantities/Duration.g.cs
index 913f041cb3..1fd3a70cb4 100644
--- a/UnitsNet/GeneratedCode/Quantities/Duration.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Duration.g.cs
@@ -663,7 +663,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Durat
/// Get from * .
public static Energy operator *(Duration duration, Power power)
{
- return Energy.FromJoules(duration.Seconds * (double)power.Watts);
+ return Energy.FromJoules(duration.Seconds * power.Watts);
}
/// Get from * .
diff --git a/UnitsNet/GeneratedCode/Quantities/Energy.g.cs b/UnitsNet/GeneratedCode/Quantities/Energy.g.cs
index 6962d9c938..305333c407 100644
--- a/UnitsNet/GeneratedCode/Quantities/Energy.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Energy.g.cs
@@ -1152,7 +1152,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Energ
/// Get from / .
public static Duration operator /(Energy energy, Power power)
{
- return Duration.FromSeconds(energy.Joules / (double)power.Watts);
+ return Duration.FromSeconds(energy.Joules / power.Watts);
}
/// Get from / .
diff --git a/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs
index 7419d2bce2..bc6331a141 100644
--- a/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs
@@ -1031,7 +1031,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassF
/// Get from / .
public static BrakeSpecificFuelConsumption operator /(MassFlow massFlow, Power power)
{
- return BrakeSpecificFuelConsumption.FromKilogramsPerJoule(massFlow.KilogramsPerSecond / (double)power.Watts);
+ return BrakeSpecificFuelConsumption.FromKilogramsPerJoule(massFlow.KilogramsPerSecond / power.Watts);
}
/// Get from / .
diff --git a/UnitsNet/GeneratedCode/Quantities/Power.g.cs b/UnitsNet/GeneratedCode/Quantities/Power.g.cs
index dc3d486953..cfd9e0cf5d 100644
--- a/UnitsNet/GeneratedCode/Quantities/Power.g.cs
+++ b/UnitsNet/GeneratedCode/Quantities/Power.g.cs
@@ -40,7 +40,7 @@ namespace UnitsNet
///
[DataContract]
public readonly partial struct Power :
- IArithmeticQuantity,
+ IArithmeticQuantity,
#if NET7_0_OR_GREATER
IDivisionOperators,
IDivisionOperators,
@@ -55,7 +55,6 @@ namespace UnitsNet
IDivisionOperators,
IDivisionOperators,
#endif
- IDecimalQuantity,
IComparable,
IComparable,
IConvertible,
@@ -66,7 +65,7 @@ namespace UnitsNet
/// The numeric value this quantity was constructed with.
///
[DataMember(Name = "Value", Order = 1)]
- private readonly decimal _value;
+ private readonly double _value;
///
/// The unit this quantity was constructed with.
@@ -122,7 +121,7 @@ static Power()
/// The numeric value to construct this quantity with.
/// The unit representation to construct this quantity with.
/// If value is NaN or Infinity.
- public Power(decimal value, PowerUnit unit)
+ public Power(double value, PowerUnit unit)
{
_value = value;
_unit = unit;
@@ -136,7 +135,7 @@ public Power(decimal value, PowerUnit unit)
/// The unit system to create the quantity with.
/// The given is null.
/// No unit was found for the given .
- public Power(decimal value, UnitSystem unitSystem)
+ public Power(double value, UnitSystem unitSystem)
{
if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem));
@@ -187,7 +186,7 @@ public Power(decimal value, UnitSystem unitSystem)
///
/// The numeric value this quantity was constructed with.
///
- public decimal Value => _value;
+ public double Value => _value;
///
QuantityValue IQuantity.Value => _value;
@@ -213,134 +212,134 @@ public Power(decimal value, UnitSystem unitSystem)
#region Conversion Properties
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal BoilerHorsepower => As(PowerUnit.BoilerHorsepower);
+ public double BoilerHorsepower => As(PowerUnit.BoilerHorsepower);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal BritishThermalUnitsPerHour => As(PowerUnit.BritishThermalUnitPerHour);
+ public double BritishThermalUnitsPerHour => As(PowerUnit.BritishThermalUnitPerHour);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal Decawatts => As(PowerUnit.Decawatt);
+ public double Decawatts => As(PowerUnit.Decawatt);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal Deciwatts => As(PowerUnit.Deciwatt);
+ public double Deciwatts => As(PowerUnit.Deciwatt);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal ElectricalHorsepower => As(PowerUnit.ElectricalHorsepower);
+ public double ElectricalHorsepower => As(PowerUnit.ElectricalHorsepower);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal Femtowatts => As(PowerUnit.Femtowatt);
+ public double Femtowatts => As(PowerUnit.Femtowatt);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal GigajoulesPerHour => As(PowerUnit.GigajoulePerHour);
+ public double GigajoulesPerHour => As(PowerUnit.GigajoulePerHour);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal Gigawatts => As(PowerUnit.Gigawatt);
+ public double Gigawatts => As(PowerUnit.Gigawatt);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal HydraulicHorsepower => As(PowerUnit.HydraulicHorsepower);
+ public double HydraulicHorsepower => As(PowerUnit.HydraulicHorsepower);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal JoulesPerHour => As(PowerUnit.JoulePerHour);
+ public double JoulesPerHour => As(PowerUnit.JoulePerHour);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal KilobritishThermalUnitsPerHour => As(PowerUnit.KilobritishThermalUnitPerHour);
+ public double KilobritishThermalUnitsPerHour => As(PowerUnit.KilobritishThermalUnitPerHour);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal KilojoulesPerHour => As(PowerUnit.KilojoulePerHour);
+ public double KilojoulesPerHour => As(PowerUnit.KilojoulePerHour);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal Kilowatts => As(PowerUnit.Kilowatt);
+ public double Kilowatts => As(PowerUnit.Kilowatt);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal MechanicalHorsepower => As(PowerUnit.MechanicalHorsepower);
+ public double MechanicalHorsepower => As(PowerUnit.MechanicalHorsepower);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal MegabritishThermalUnitsPerHour => As(PowerUnit.MegabritishThermalUnitPerHour);
+ public double MegabritishThermalUnitsPerHour => As(PowerUnit.MegabritishThermalUnitPerHour);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal MegajoulesPerHour => As(PowerUnit.MegajoulePerHour);
+ public double MegajoulesPerHour => As(PowerUnit.MegajoulePerHour);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal Megawatts => As(PowerUnit.Megawatt);
+ public double Megawatts => As(PowerUnit.Megawatt);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal MetricHorsepower => As(PowerUnit.MetricHorsepower);
+ public double MetricHorsepower => As(PowerUnit.MetricHorsepower);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal Microwatts => As(PowerUnit.Microwatt);
+ public double Microwatts => As(PowerUnit.Microwatt);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal MillijoulesPerHour => As(PowerUnit.MillijoulePerHour);
+ public double MillijoulesPerHour => As(PowerUnit.MillijoulePerHour);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal Milliwatts => As(PowerUnit.Milliwatt);
+ public double Milliwatts => As(PowerUnit.Milliwatt);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal Nanowatts => As(PowerUnit.Nanowatt);
+ public double Nanowatts => As(PowerUnit.Nanowatt);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal Petawatts => As(PowerUnit.Petawatt);
+ public double Petawatts => As(PowerUnit.Petawatt);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal Picowatts => As(PowerUnit.Picowatt);
+ public double Picowatts => As(PowerUnit.Picowatt);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal Terawatts => As(PowerUnit.Terawatt);
+ public double Terawatts => As(PowerUnit.Terawatt);
///
- /// Gets a value of this quantity converted into
+ /// Gets a value of this quantity converted into
///
- public decimal Watts => As(PowerUnit.Watt);
+ public double Watts => As(PowerUnit.Watt);
#endregion
@@ -441,7 +440,7 @@ public static string GetAbbreviation(PowerUnit unit, IFormatProvider? provider)
/// If value is NaN or Infinity.
public static Power FromBoilerHorsepower(QuantityValue boilerhorsepower)
{
- decimal value = (decimal) boilerhorsepower;
+ double value = (double) boilerhorsepower;
return new Power(value, PowerUnit.BoilerHorsepower);
}
@@ -451,7 +450,7 @@ public static Power FromBoilerHorsepower(QuantityValue boilerhorsepower)
/// If value is NaN or Infinity.
public static Power FromBritishThermalUnitsPerHour(QuantityValue britishthermalunitsperhour)
{
- decimal value = (decimal) britishthermalunitsperhour;
+ double value = (double) britishthermalunitsperhour;
return new Power(value, PowerUnit.BritishThermalUnitPerHour);
}
@@ -461,7 +460,7 @@ public static Power FromBritishThermalUnitsPerHour(QuantityValue britishthermalu
/// If value is NaN or Infinity.
public static Power FromDecawatts(QuantityValue decawatts)
{
- decimal value = (decimal) decawatts;
+ double value = (double) decawatts;
return new Power(value, PowerUnit.Decawatt);
}
@@ -471,7 +470,7 @@ public static Power FromDecawatts(QuantityValue decawatts)
/// If value is NaN or Infinity.
public static Power FromDeciwatts(QuantityValue deciwatts)
{
- decimal value = (decimal) deciwatts;
+ double value = (double) deciwatts;
return new Power(value, PowerUnit.Deciwatt);
}
@@ -481,7 +480,7 @@ public static Power FromDeciwatts(QuantityValue deciwatts)
/// If value is NaN or Infinity.
public static Power FromElectricalHorsepower(QuantityValue electricalhorsepower)
{
- decimal value = (decimal) electricalhorsepower;
+ double value = (double) electricalhorsepower;
return new Power(value, PowerUnit.ElectricalHorsepower);
}
@@ -491,7 +490,7 @@ public static Power FromElectricalHorsepower(QuantityValue electricalhorsepower)
/// If value is NaN or Infinity.
public static Power FromFemtowatts(QuantityValue femtowatts)
{
- decimal value = (decimal) femtowatts;
+ double value = (double) femtowatts;
return new Power(value, PowerUnit.Femtowatt);
}
@@ -501,7 +500,7 @@ public static Power FromFemtowatts(QuantityValue femtowatts)
/// If value is NaN or Infinity.
public static Power FromGigajoulesPerHour(QuantityValue gigajoulesperhour)
{
- decimal value = (decimal) gigajoulesperhour;
+ double value = (double) gigajoulesperhour;
return new Power(value, PowerUnit.GigajoulePerHour);
}
@@ -511,7 +510,7 @@ public static Power FromGigajoulesPerHour(QuantityValue gigajoulesperhour)
/// If value is NaN or Infinity.
public static Power FromGigawatts(QuantityValue gigawatts)
{
- decimal value = (decimal) gigawatts;
+ double value = (double) gigawatts;
return new Power(value, PowerUnit.Gigawatt);
}
@@ -521,7 +520,7 @@ public static Power FromGigawatts(QuantityValue gigawatts)
/// If value is NaN or Infinity.
public static Power FromHydraulicHorsepower(QuantityValue hydraulichorsepower)
{
- decimal value = (decimal) hydraulichorsepower;
+ double value = (double) hydraulichorsepower;
return new Power(value, PowerUnit.HydraulicHorsepower);
}
@@ -531,7 +530,7 @@ public static Power FromHydraulicHorsepower(QuantityValue hydraulichorsepower)
/// If value is NaN or Infinity.
public static Power FromJoulesPerHour(QuantityValue joulesperhour)
{
- decimal value = (decimal) joulesperhour;
+ double value = (double) joulesperhour;
return new Power(value, PowerUnit.JoulePerHour);
}
@@ -541,7 +540,7 @@ public static Power FromJoulesPerHour(QuantityValue joulesperhour)
/// If value is NaN or Infinity.
public static Power FromKilobritishThermalUnitsPerHour(QuantityValue kilobritishthermalunitsperhour)
{
- decimal value = (decimal) kilobritishthermalunitsperhour;
+ double value = (double) kilobritishthermalunitsperhour;
return new Power(value, PowerUnit.KilobritishThermalUnitPerHour);
}
@@ -551,7 +550,7 @@ public static Power FromKilobritishThermalUnitsPerHour(QuantityValue kilobritish
/// If value is NaN or Infinity.
public static Power FromKilojoulesPerHour(QuantityValue kilojoulesperhour)
{
- decimal value = (decimal) kilojoulesperhour;
+ double value = (double) kilojoulesperhour;
return new Power(value, PowerUnit.KilojoulePerHour);
}
@@ -561,7 +560,7 @@ public static Power FromKilojoulesPerHour(QuantityValue kilojoulesperhour)
/// If value is NaN or Infinity.
public static Power FromKilowatts(QuantityValue kilowatts)
{
- decimal value = (decimal) kilowatts;
+ double value = (double) kilowatts;
return new Power(value, PowerUnit.Kilowatt);
}
@@ -571,7 +570,7 @@ public static Power FromKilowatts(QuantityValue kilowatts)
/// If value is NaN or Infinity.
public static Power FromMechanicalHorsepower(QuantityValue mechanicalhorsepower)
{
- decimal value = (decimal) mechanicalhorsepower;
+ double value = (double) mechanicalhorsepower;
return new Power(value, PowerUnit.MechanicalHorsepower);
}
@@ -581,7 +580,7 @@ public static Power FromMechanicalHorsepower(QuantityValue mechanicalhorsepower)
/// If value is NaN or Infinity.
public static Power FromMegabritishThermalUnitsPerHour(QuantityValue megabritishthermalunitsperhour)
{
- decimal value = (decimal) megabritishthermalunitsperhour;
+ double value = (double) megabritishthermalunitsperhour;
return new Power(value, PowerUnit.MegabritishThermalUnitPerHour);
}
@@ -591,7 +590,7 @@ public static Power FromMegabritishThermalUnitsPerHour(QuantityValue megabritish
/// If value is NaN or Infinity.
public static Power FromMegajoulesPerHour(QuantityValue megajoulesperhour)
{
- decimal value = (decimal) megajoulesperhour;
+ double value = (double) megajoulesperhour;
return new Power(value, PowerUnit.MegajoulePerHour);
}
@@ -601,7 +600,7 @@ public static Power FromMegajoulesPerHour(QuantityValue megajoulesperhour)
/// If value is NaN or Infinity.
public static Power FromMegawatts(QuantityValue megawatts)
{
- decimal value = (decimal) megawatts;
+ double value = (double) megawatts;
return new Power(value, PowerUnit.Megawatt);
}
@@ -611,7 +610,7 @@ public static Power FromMegawatts(QuantityValue megawatts)
/// If value is NaN or Infinity.
public static Power FromMetricHorsepower(QuantityValue metrichorsepower)
{
- decimal value = (decimal) metrichorsepower;
+ double value = (double) metrichorsepower;
return new Power(value, PowerUnit.MetricHorsepower);
}
@@ -621,7 +620,7 @@ public static Power FromMetricHorsepower(QuantityValue metrichorsepower)
/// If value is NaN or Infinity.
public static Power FromMicrowatts(QuantityValue microwatts)
{
- decimal value = (decimal) microwatts;
+ double value = (double) microwatts;
return new Power(value, PowerUnit.Microwatt);
}
@@ -631,7 +630,7 @@ public static Power FromMicrowatts(QuantityValue microwatts)
/// If value is NaN or Infinity.
public static Power FromMillijoulesPerHour(QuantityValue millijoulesperhour)
{
- decimal value = (decimal) millijoulesperhour;
+ double value = (double) millijoulesperhour;
return new Power(value, PowerUnit.MillijoulePerHour);
}
@@ -641,7 +640,7 @@ public static Power FromMillijoulesPerHour(QuantityValue millijoulesperhour)
/// If value is NaN or Infinity.
public static Power FromMilliwatts(QuantityValue milliwatts)
{
- decimal value = (decimal) milliwatts;
+ double value = (double) milliwatts;
return new Power(value, PowerUnit.Milliwatt);
}
@@ -651,7 +650,7 @@ public static Power FromMilliwatts(QuantityValue milliwatts)
/// If value is NaN or Infinity.
public static Power FromNanowatts(QuantityValue nanowatts)
{
- decimal value = (decimal) nanowatts;
+ double value = (double) nanowatts;
return new Power(value, PowerUnit.Nanowatt);
}
@@ -661,7 +660,7 @@ public static Power FromNanowatts(QuantityValue nanowatts)
/// If value is NaN or Infinity.
public static Power FromPetawatts(QuantityValue petawatts)
{
- decimal value = (decimal) petawatts;
+ double value = (double) petawatts;
return new Power(value, PowerUnit.Petawatt);
}
@@ -671,7 +670,7 @@ public static Power FromPetawatts(QuantityValue petawatts)
/// If value is NaN or Infinity.
public static Power FromPicowatts(QuantityValue picowatts)
{
- decimal value = (decimal) picowatts;
+ double value = (double) picowatts;
return new Power(value, PowerUnit.Picowatt);
}
@@ -681,7 +680,7 @@ public static Power FromPicowatts(QuantityValue picowatts)
/// If value is NaN or Infinity.
public static Power FromTerawatts(QuantityValue terawatts)
{
- decimal value = (decimal) terawatts;
+ double value = (double) terawatts;
return new Power(value, PowerUnit.Terawatt);
}
@@ -691,7 +690,7 @@ public static Power FromTerawatts(QuantityValue terawatts)
/// If value is NaN or Infinity.
public static Power FromWatts(QuantityValue watts)
{
- decimal value = (decimal) watts;
+ double value = (double) watts;
return new Power(value, PowerUnit.Watt);
}
@@ -703,7 +702,7 @@ public static Power FromWatts(QuantityValue watts)
/// Power unit value.
public static Power From(QuantityValue value, PowerUnit fromUnit)
{
- return new Power((decimal)value, fromUnit);
+ return new Power((double)value, fromUnit);
}
#endregion
@@ -873,25 +872,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Power
}
/// Get from multiplying value and .
- public static Power operator *(decimal left, Power right)
+ public static Power operator *(double left, Power right)
{
return new Power(left * right.Value, right.Unit);
}
/// Get from multiplying value and .
- public static Power operator *(Power left, decimal right)
+ public static Power operator *(Power left, double right)
{
return new Power(left.Value * right, left.Unit);
}
/// Get from dividing by value.
- public static Power operator /(Power left, decimal right)
+ public static Power operator /(Power left, double right)
{
return new Power(left.Value / right, left.Unit);
}
/// Get ratio value from dividing by .
- public static decimal operator /(Power left, Power right)
+ public static double operator /(Power left, Power right)
{
return left.Watts / right.Watts;
}
@@ -903,79 +902,79 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Power
/// Get from / .
public static Area operator /(Power power, HeatFlux heatFlux)
{
- return Area.FromSquareMeters((double)power.Watts / heatFlux.WattsPerSquareMeter);
+ return Area.FromSquareMeters(power.Watts / heatFlux.WattsPerSquareMeter);
}
/// Get from / .
public static ElectricCurrent operator /(Power power, ElectricPotential electricPotential)
{
- return ElectricCurrent.FromAmperes((double)power.Watts / electricPotential.Volts);
+ return ElectricCurrent.FromAmperes(power.Watts / electricPotential.Volts);
}
/// Get from / .
public static ElectricPotential operator /(Power power, ElectricCurrent electricCurrent)
{
- return ElectricPotential.FromVolts((double)power.Watts / electricCurrent.Amperes);
+ return ElectricPotential.FromVolts(power.Watts / electricCurrent.Amperes);
}
/// Get from * .
public static Energy operator *(Power power, Duration duration)
{
- return Energy.FromJoules((double)power.Watts * duration.Seconds);
+ return Energy.FromJoules(power.Watts * duration.Seconds);
}
/// Get from * .
public static Energy operator *(Power power, TimeSpan timeSpan)
{
- return Energy.FromJoules((double)power.Watts * timeSpan.TotalSeconds);
+ return Energy.FromJoules(power.Watts * timeSpan.TotalSeconds);
}
/// Get from * .
public static Energy operator *(TimeSpan timeSpan, Power power)
{
- return Energy.FromJoules(timeSpan.TotalSeconds * (double)power.Watts);
+ return Energy.FromJoules(timeSpan.TotalSeconds * power.Watts);
}
/// Get from / .
public static Force operator /(Power power, Speed speed)
{
- return Force.FromNewtons((double)power.Watts / speed.MetersPerSecond);
+ return Force.FromNewtons(power.Watts / speed.MetersPerSecond);
}
/// Get from / .
public static HeatFlux operator /(Power power, Area area)
{
- return HeatFlux.FromWattsPerSquareMeter((double)power.Watts / area.SquareMeters);
+ return HeatFlux.FromWattsPerSquareMeter(power.Watts / area.SquareMeters);
}
/// Get from * .
public static MassFlow operator *(Power power, BrakeSpecificFuelConsumption brakeSpecificFuelConsumption)
{
- return MassFlow.FromKilogramsPerSecond((double)power.Watts * brakeSpecificFuelConsumption.KilogramsPerJoule);
+ return MassFlow.FromKilogramsPerSecond(power.Watts * brakeSpecificFuelConsumption.KilogramsPerJoule);
}
/// Get from / .
public static MassFlow operator /(Power power, SpecificEnergy specificEnergy)
{
- return MassFlow.FromKilogramsPerSecond((double)power.Watts / specificEnergy.JoulesPerKilogram);
+ return MassFlow.FromKilogramsPerSecond(power.Watts / specificEnergy.JoulesPerKilogram);
}
/// Get from / .
public static RotationalSpeed operator /(Power power, Torque torque)
{
- return RotationalSpeed.FromRadiansPerSecond((double)power.Watts / torque.NewtonMeters);
+ return RotationalSpeed.FromRadiansPerSecond(power.Watts / torque.NewtonMeters);
}
/// Get from / .
public static SpecificEnergy operator /(Power power, MassFlow massFlow)
{
- return SpecificEnergy.FromJoulesPerKilogram((double)power.Watts / massFlow.KilogramsPerSecond);
+ return SpecificEnergy.FromJoulesPerKilogram(power.Watts / massFlow.KilogramsPerSecond);
}
/// Get from / .
public static Torque operator /(Power power, RotationalSpeed rotationalSpeed)
{
- return Torque.FromNewtonMeters((double)power.Watts / rotationalSpeed.RadiansPerSecond);
+ return Torque.FromNewtonMeters(power.Watts / rotationalSpeed.RadiansPerSecond);
}
#endregion
@@ -1114,7 +1113,7 @@ public int CompareTo(Power other)
///
///
/// Note that it is advised against specifying zero difference, due to the nature
- /// of floating-point operations and using decimal internally.
+ /// of floating-point operations and using double internally.
///
///
/// The other quantity to compare to.
@@ -1122,7 +1121,7 @@ public int CompareTo(Power other)
/// The comparison type: either relative or absolute.
/// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance.
[Obsolete("Use Equals(Power other, Power tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units.")]
- public bool Equals(Power other, decimal tolerance, ComparisonType comparisonType)
+ public bool Equals(Power other, double tolerance, ComparisonType comparisonType)
{
if (tolerance < 0)
throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0.");
@@ -1171,7 +1170,7 @@ public override int GetHashCode()
/// Convert to the unit representation .
///
/// Value converted to the specified unit.
- public decimal As(PowerUnit unit)
+ public double As(PowerUnit unit)
{
if (Unit == unit)
return Value;
@@ -1179,13 +1178,8 @@ public decimal As(PowerUnit unit)
return ToUnit(unit).Value;
}
- double IQuantity.As(PowerUnit unit)
- {
- return (double)As(unit);
- }
-
///
- public decimal As(UnitSystem unitSystem)
+ public double As(UnitSystem unitSystem)
{
if (unitSystem is null)
throw new ArgumentNullException(nameof(unitSystem));
@@ -1199,12 +1193,6 @@ public decimal As(UnitSystem unitSystem)
return As(firstUnitInfo.Value);
}
- ///
- double IQuantity.As(UnitSystem unitSystem)
- {
- return (double)As(unitSystem);
- }
-
///
double IQuantity.As(Enum unit)
{
@@ -1215,7 +1203,7 @@ double IQuantity.As(Enum unit)
}
///
- decimal IValueQuantity.As(Enum unit)
+ double IValueQuantity.As(Enum unit)
{
if (!(unit is PowerUnit typedUnit))
throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PowerUnit)} is supported.", nameof(unit));
@@ -1281,58 +1269,58 @@ private bool TryToUnit(PowerUnit unit, [NotNullWhen(true)] out Power? converted)
Power? convertedOrNull = (Unit, unit) switch
{
// PowerUnit -> BaseUnit
- (PowerUnit.BoilerHorsepower, PowerUnit.Watt) => new Power(_value * 9812.5m, PowerUnit.Watt),
- (PowerUnit.BritishThermalUnitPerHour, PowerUnit.Watt) => new Power(_value * 0.29307107017m, PowerUnit.Watt),
- (PowerUnit.Decawatt, PowerUnit.Watt) => new Power((_value) * 1e1m, PowerUnit.Watt),
- (PowerUnit.Deciwatt, PowerUnit.Watt) => new Power((_value) * 1e-1m, PowerUnit.Watt),
- (PowerUnit.ElectricalHorsepower, PowerUnit.Watt) => new Power(_value * 746m, PowerUnit.Watt),
- (PowerUnit.Femtowatt, PowerUnit.Watt) => new Power((_value) * 1e-15m, PowerUnit.Watt),
- (PowerUnit.GigajoulePerHour, PowerUnit.Watt) => new Power((_value / 3600m) * 1e9m, PowerUnit.Watt),
- (PowerUnit.Gigawatt, PowerUnit.Watt) => new Power((_value) * 1e9m, PowerUnit.Watt),
- (PowerUnit.HydraulicHorsepower, PowerUnit.Watt) => new Power(_value * 745.69988145m, PowerUnit.Watt),
- (PowerUnit.JoulePerHour, PowerUnit.Watt) => new Power(_value / 3600m, PowerUnit.Watt),
- (PowerUnit.KilobritishThermalUnitPerHour, PowerUnit.Watt) => new Power((_value * 0.29307107017m) * 1e3m, PowerUnit.Watt),
- (PowerUnit.KilojoulePerHour, PowerUnit.Watt) => new Power((_value / 3600m) * 1e3m, PowerUnit.Watt),
- (PowerUnit.Kilowatt, PowerUnit.Watt) => new Power((_value) * 1e3m, PowerUnit.Watt),
- (PowerUnit.MechanicalHorsepower, PowerUnit.Watt) => new Power(_value * 745.69m, PowerUnit.Watt),
- (PowerUnit.MegabritishThermalUnitPerHour, PowerUnit.Watt) => new Power((_value * 0.29307107017m) * 1e6m, PowerUnit.Watt),
- (PowerUnit.MegajoulePerHour, PowerUnit.Watt) => new Power((_value / 3600m) * 1e6m, PowerUnit.Watt),
- (PowerUnit.Megawatt, PowerUnit.Watt) => new Power((_value) * 1e6m, PowerUnit.Watt),
- (PowerUnit.MetricHorsepower, PowerUnit.Watt) => new Power(_value * 735.49875m, PowerUnit.Watt),
- (PowerUnit.Microwatt, PowerUnit.Watt) => new Power((_value) * 1e-6m, PowerUnit.Watt),
- (PowerUnit.MillijoulePerHour, PowerUnit.Watt) => new Power((_value / 3600m) * 1e-3m, PowerUnit.Watt),
- (PowerUnit.Milliwatt, PowerUnit.Watt) => new Power((_value) * 1e-3m, PowerUnit.Watt),
- (PowerUnit.Nanowatt, PowerUnit.Watt) => new Power((_value) * 1e-9m, PowerUnit.Watt),
- (PowerUnit.Petawatt, PowerUnit.Watt) => new Power((_value) * 1e15m, PowerUnit.Watt),
- (PowerUnit.Picowatt, PowerUnit.Watt) => new Power((_value) * 1e-12m, PowerUnit.Watt),
- (PowerUnit.Terawatt, PowerUnit.Watt) => new Power((_value) * 1e12m, PowerUnit.Watt),
+ (PowerUnit.BoilerHorsepower, PowerUnit.Watt) => new Power(_value * 9812.5, PowerUnit.Watt),
+ (PowerUnit.BritishThermalUnitPerHour, PowerUnit.Watt) => new Power(_value * 0.29307107017, PowerUnit.Watt),
+ (PowerUnit.Decawatt, PowerUnit.Watt) => new Power((_value) * 1e1d, PowerUnit.Watt),
+ (PowerUnit.Deciwatt, PowerUnit.Watt) => new Power((_value) * 1e-1d, PowerUnit.Watt),
+ (PowerUnit.ElectricalHorsepower, PowerUnit.Watt) => new Power(_value * 746, PowerUnit.Watt),
+ (PowerUnit.Femtowatt, PowerUnit.Watt) => new Power((_value) * 1e-15d, PowerUnit.Watt),
+ (PowerUnit.GigajoulePerHour, PowerUnit.Watt) => new Power((_value / 3600) * 1e9d, PowerUnit.Watt),
+ (PowerUnit.Gigawatt, PowerUnit.Watt) => new Power((_value) * 1e9d, PowerUnit.Watt),
+ (PowerUnit.HydraulicHorsepower, PowerUnit.Watt) => new Power(_value * 745.69988145, PowerUnit.Watt),
+ (PowerUnit.JoulePerHour, PowerUnit.Watt) => new Power(_value / 3600, PowerUnit.Watt),
+ (PowerUnit.KilobritishThermalUnitPerHour, PowerUnit.Watt) => new Power((_value * 0.29307107017) * 1e3d, PowerUnit.Watt),
+ (PowerUnit.KilojoulePerHour, PowerUnit.Watt) => new Power((_value / 3600) * 1e3d, PowerUnit.Watt),
+ (PowerUnit.Kilowatt, PowerUnit.Watt) => new Power((_value) * 1e3d, PowerUnit.Watt),
+ (PowerUnit.MechanicalHorsepower, PowerUnit.Watt) => new Power(_value * 745.69, PowerUnit.Watt),
+ (PowerUnit.MegabritishThermalUnitPerHour, PowerUnit.Watt) => new Power((_value * 0.29307107017) * 1e6d, PowerUnit.Watt),
+ (PowerUnit.MegajoulePerHour, PowerUnit.Watt) => new Power((_value / 3600) * 1e6d, PowerUnit.Watt),
+ (PowerUnit.Megawatt, PowerUnit.Watt) => new Power((_value) * 1e6d, PowerUnit.Watt),
+ (PowerUnit.MetricHorsepower, PowerUnit.Watt) => new Power(_value * 735.49875, PowerUnit.Watt),
+ (PowerUnit.Microwatt, PowerUnit.Watt) => new Power((_value) * 1e-6d, PowerUnit.Watt),
+ (PowerUnit.MillijoulePerHour, PowerUnit.Watt) => new Power((_value / 3600) * 1e-3d, PowerUnit.Watt),
+ (PowerUnit.Milliwatt, PowerUnit.Watt) => new Power((_value) * 1e-3d, PowerUnit.Watt),
+ (PowerUnit.Nanowatt, PowerUnit.Watt) => new Power((_value) * 1e-9d, PowerUnit.Watt),
+ (PowerUnit.Petawatt, PowerUnit.Watt) => new Power((_value) * 1e15d, PowerUnit.Watt),
+ (PowerUnit.Picowatt, PowerUnit.Watt) => new Power((_value) * 1e-12d, PowerUnit.Watt),
+ (PowerUnit.Terawatt, PowerUnit.Watt) => new Power((_value) * 1e12d, PowerUnit.Watt),
// BaseUnit -> PowerUnit
- (PowerUnit.Watt, PowerUnit.BoilerHorsepower) => new Power(_value / 9812.5m, PowerUnit.BoilerHorsepower),
- (PowerUnit.Watt, PowerUnit.BritishThermalUnitPerHour) => new Power(_value / 0.29307107017m, PowerUnit.BritishThermalUnitPerHour),
- (PowerUnit.Watt, PowerUnit.Decawatt) => new Power((_value) / 1e1m, PowerUnit.Decawatt),
- (PowerUnit.Watt, PowerUnit.Deciwatt) => new Power((_value) / 1e-1m, PowerUnit.Deciwatt),
- (PowerUnit.Watt, PowerUnit.ElectricalHorsepower) => new Power(_value / 746m, PowerUnit.ElectricalHorsepower),
- (PowerUnit.Watt, PowerUnit.Femtowatt) => new Power((_value) / 1e-15m, PowerUnit.Femtowatt),
- (PowerUnit.Watt, PowerUnit.GigajoulePerHour) => new Power((_value * 3600m) / 1e9m, PowerUnit.GigajoulePerHour),
- (PowerUnit.Watt, PowerUnit.Gigawatt) => new Power((_value) / 1e9m, PowerUnit.Gigawatt),
- (PowerUnit.Watt, PowerUnit.HydraulicHorsepower) => new Power(_value / 745.69988145m, PowerUnit.HydraulicHorsepower),
- (PowerUnit.Watt, PowerUnit.JoulePerHour) => new Power(_value * 3600m, PowerUnit.JoulePerHour),
- (PowerUnit.Watt, PowerUnit.KilobritishThermalUnitPerHour) => new Power((_value / 0.29307107017m) / 1e3m, PowerUnit.KilobritishThermalUnitPerHour),
- (PowerUnit.Watt, PowerUnit.KilojoulePerHour) => new Power((_value * 3600m) / 1e3m, PowerUnit.KilojoulePerHour),
- (PowerUnit.Watt, PowerUnit.Kilowatt) => new Power((_value) / 1e3m, PowerUnit.Kilowatt),
- (PowerUnit.Watt, PowerUnit.MechanicalHorsepower) => new Power(_value / 745.69m, PowerUnit.MechanicalHorsepower),
- (PowerUnit.Watt, PowerUnit.MegabritishThermalUnitPerHour) => new Power((_value / 0.29307107017m) / 1e6m, PowerUnit.MegabritishThermalUnitPerHour),
- (PowerUnit.Watt, PowerUnit.MegajoulePerHour) => new Power((_value * 3600m) / 1e6m, PowerUnit.MegajoulePerHour),
- (PowerUnit.Watt, PowerUnit.Megawatt) => new Power((_value) / 1e6m, PowerUnit.Megawatt),
- (PowerUnit.Watt, PowerUnit.MetricHorsepower) => new Power(_value / 735.49875m, PowerUnit.MetricHorsepower),
- (PowerUnit.Watt, PowerUnit.Microwatt) => new Power((_value) / 1e-6m, PowerUnit.Microwatt),
- (PowerUnit.Watt, PowerUnit.MillijoulePerHour) => new Power((_value * 3600m) / 1e-3m, PowerUnit.MillijoulePerHour),
- (PowerUnit.Watt, PowerUnit.Milliwatt) => new Power((_value) / 1e-3m, PowerUnit.Milliwatt),
- (PowerUnit.Watt, PowerUnit.Nanowatt) => new Power((_value) / 1e-9m, PowerUnit.Nanowatt),
- (PowerUnit.Watt, PowerUnit.Petawatt) => new Power((_value) / 1e15m, PowerUnit.Petawatt),
- (PowerUnit.Watt, PowerUnit.Picowatt) => new Power((_value) / 1e-12m, PowerUnit.Picowatt),
- (PowerUnit.Watt, PowerUnit.Terawatt) => new Power((_value) / 1e12m, PowerUnit.Terawatt),
+ (PowerUnit.Watt, PowerUnit.BoilerHorsepower) => new Power(_value / 9812.5, PowerUnit.BoilerHorsepower),
+ (PowerUnit.Watt, PowerUnit.BritishThermalUnitPerHour) => new Power(_value / 0.29307107017, PowerUnit.BritishThermalUnitPerHour),
+ (PowerUnit.Watt, PowerUnit.Decawatt) => new Power((_value) / 1e1d, PowerUnit.Decawatt),
+ (PowerUnit.Watt, PowerUnit.Deciwatt) => new Power((_value) / 1e-1d, PowerUnit.Deciwatt),
+ (PowerUnit.Watt, PowerUnit.ElectricalHorsepower) => new Power(_value / 746, PowerUnit.ElectricalHorsepower),
+ (PowerUnit.Watt, PowerUnit.Femtowatt) => new Power((_value) / 1e-15d, PowerUnit.Femtowatt),
+ (PowerUnit.Watt, PowerUnit.GigajoulePerHour) => new Power((_value * 3600) / 1e9d, PowerUnit.GigajoulePerHour),
+ (PowerUnit.Watt, PowerUnit.Gigawatt) => new Power((_value) / 1e9d, PowerUnit.Gigawatt),
+ (PowerUnit.Watt, PowerUnit.HydraulicHorsepower) => new Power(_value / 745.69988145, PowerUnit.HydraulicHorsepower),
+ (PowerUnit.Watt, PowerUnit.JoulePerHour) => new Power(_value * 3600, PowerUnit.JoulePerHour),
+ (PowerUnit.Watt, PowerUnit.KilobritishThermalUnitPerHour) => new Power((_value / 0.29307107017) / 1e3d, PowerUnit.KilobritishThermalUnitPerHour),
+ (PowerUnit.Watt, PowerUnit.KilojoulePerHour) => new Power((_value * 3600) / 1e3d, PowerUnit.KilojoulePerHour),
+ (PowerUnit.Watt, PowerUnit.Kilowatt) => new Power((_value) / 1e3d, PowerUnit.Kilowatt),
+ (PowerUnit.Watt, PowerUnit.MechanicalHorsepower) => new Power(_value / 745.69, PowerUnit.MechanicalHorsepower),
+ (PowerUnit.Watt, PowerUnit.MegabritishThermalUnitPerHour) => new Power((_value / 0.29307107017) / 1e6d, PowerUnit.MegabritishThermalUnitPerHour),
+ (PowerUnit.Watt, PowerUnit.MegajoulePerHour) => new Power((_value * 3600) / 1e6d, PowerUnit.MegajoulePerHour),
+ (PowerUnit.Watt, PowerUnit.Megawatt) => new Power((_value) / 1e6d, PowerUnit.Megawatt),
+ (PowerUnit.Watt, PowerUnit.MetricHorsepower) => new Power(_value / 735.49875, PowerUnit.MetricHorsepower),
+ (PowerUnit.Watt, PowerUnit.Microwatt) => new Power((_value) / 1e-6d, PowerUnit.Microwatt),
+ (PowerUnit.Watt, PowerUnit.MillijoulePerHour) => new Power((_value * 3600) / 1e-3d, PowerUnit.MillijoulePerHour),
+ (PowerUnit.Watt, PowerUnit.Milliwatt) => new Power((_value) / 1e-3d, PowerUnit.Milliwatt),
+ (PowerUnit.Watt, PowerUnit.Nanowatt) => new Power((_value) / 1e-9d, PowerUnit.Nanowatt),
+ (PowerUnit.Watt, PowerUnit.Petawatt) => new Power((_value) / 1e15d, PowerUnit.Petawatt),
+ (PowerUnit.Watt, PowerUnit.Picowatt) => new Power((_value) / 1e-12d, PowerUnit.Picowatt),
+ (PowerUnit.Watt, PowerUnit.Terawatt) => new Power((_value) / 1e12d, PowerUnit.Terawatt),
_ => null
};
@@ -1381,7 +1369,7 @@ public Power ToUnit(UnitSystem unitSystem)
IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem);
///
- IValueQuantity IValueQuantity.ToUnit(Enum unit)
+ IValueQuantity IValueQuantity.ToUnit(Enum unit)
{
if (unit is not PowerUnit typedUnit)
throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PowerUnit)} is supported.", nameof(unit));
@@ -1390,7 +1378,7 @@ IValueQuantity IValueQuantity.ToUnit(Enum unit)
}
///
- IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem);
+ IValueQuantity IValueQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem);
#endregion