Skip to content

Commit 3e99347

Browse files
tmilnthorpangularsen
authored andcommitted
Convert Power to double
1 parent 31562eb commit 3e99347

File tree

14 files changed

+321
-311
lines changed

14 files changed

+321
-311
lines changed

Common/UnitDefinitions/Power.json

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"Name": "Power",
33
"BaseUnit": "Watt",
4-
"ValueType": "decimal",
54
"XmlDocSummary": "In physics, power is the rate of doing work. It is equivalent to an amount of energy consumed per unit time.",
65
"BaseDimensions": {
76
"L": 2,
@@ -25,8 +24,8 @@
2524
{
2625
"SingularName": "MechanicalHorsepower",
2726
"PluralName": "MechanicalHorsepower",
28-
"FromUnitToBaseFunc": "{x} * 745.69m",
29-
"FromBaseToUnitFunc": "{x} / 745.69m",
27+
"FromUnitToBaseFunc": "{x} * 745.69",
28+
"FromBaseToUnitFunc": "{x} / 745.69",
3029
"Localization": [
3130
{
3231
"Culture": "en-US",
@@ -37,8 +36,8 @@
3736
{
3837
"SingularName": "MetricHorsepower",
3938
"PluralName": "MetricHorsepower",
40-
"FromUnitToBaseFunc": "{x} * 735.49875m",
41-
"FromBaseToUnitFunc": "{x} / 735.49875m",
39+
"FromUnitToBaseFunc": "{x} * 735.49875",
40+
"FromBaseToUnitFunc": "{x} / 735.49875",
4241
"Localization": [
4342
{
4443
"Culture": "en-US",
@@ -49,8 +48,8 @@
4948
{
5049
"SingularName": "ElectricalHorsepower",
5150
"PluralName": "ElectricalHorsepower",
52-
"FromUnitToBaseFunc": "{x} * 746m",
53-
"FromBaseToUnitFunc": "{x} / 746m",
51+
"FromUnitToBaseFunc": "{x} * 746",
52+
"FromBaseToUnitFunc": "{x} / 746",
5453
"Localization": [
5554
{
5655
"Culture": "en-US",
@@ -61,8 +60,8 @@
6160
{
6261
"SingularName": "BoilerHorsepower",
6362
"PluralName": "BoilerHorsepower",
64-
"FromUnitToBaseFunc": "{x} * 9812.5m",
65-
"FromBaseToUnitFunc": "{x} / 9812.5m",
63+
"FromUnitToBaseFunc": "{x} * 9812.5",
64+
"FromBaseToUnitFunc": "{x} / 9812.5",
6665
"Localization": [
6766
{
6867
"Culture": "en-US",
@@ -73,8 +72,8 @@
7372
{
7473
"SingularName": "HydraulicHorsepower",
7574
"PluralName": "HydraulicHorsepower",
76-
"FromUnitToBaseFunc": "{x} * 745.69988145m",
77-
"FromBaseToUnitFunc": "{x} / 745.69988145m",
75+
"FromUnitToBaseFunc": "{x} * 745.69988145",
76+
"FromBaseToUnitFunc": "{x} / 745.69988145",
7877
"Localization": [
7978
{
8079
"Culture": "en-US",
@@ -85,8 +84,8 @@
8584
{
8685
"SingularName": "BritishThermalUnitPerHour",
8786
"PluralName": "BritishThermalUnitsPerHour",
88-
"FromUnitToBaseFunc": "{x} * 0.29307107017m",
89-
"FromBaseToUnitFunc": "{x} / 0.29307107017m",
87+
"FromUnitToBaseFunc": "{x} * 0.29307107017",
88+
"FromBaseToUnitFunc": "{x} / 0.29307107017",
9089
"Prefixes": [ "Kilo", "Mega" ],
9190
"Localization": [
9291
{
@@ -98,8 +97,8 @@
9897
{
9998
"SingularName": "JoulePerHour",
10099
"PluralName": "JoulesPerHour",
101-
"FromUnitToBaseFunc": "{x} / 3600m",
102-
"FromBaseToUnitFunc": "{x} * 3600m",
100+
"FromUnitToBaseFunc": "{x} / 3600",
101+
"FromBaseToUnitFunc": "{x} * 3600",
103102
"Prefixes": [ "Milli", "Kilo", "Mega", "Giga" ],
104103
"Localization": [
105104
{

UnitsNet.NanoFramework/GeneratedCode/Quantities/Power.g.cs

Lines changed: 28 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UnitsNet.Serialization.JsonNet.Tests/UnitsNetBaseJsonConverterTest.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ public void UnitsNetBaseJsonConverter_ConvertValueUnit_works_as_expected()
5454

5555
Assert.NotNull(result);
5656
Assert.IsType<Power>(result);
57-
Assert.True(Power.FromWatts(10.2365m).Equals((Power)result, 1E-5m, ComparisonType.Absolute));
58-
57+
Assert.True(Power.FromWatts(10.2365).Equals((Power)result, 1e-5, ComparisonType.Absolute));
5958
}
6059

6160
[Fact]

UnitsNet.Serialization.JsonNet.Tests/UnitsNetIComparableJsonConverterTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public void UnitsNetIComparableJsonConverter_ReadJson_works_as_expected()
119119

120120
Assert.NotNull(result);
121121
Assert.IsType<Power>(result);
122-
Assert.Equal(120M, ((Power)result).Watts);
122+
Assert.Equal(120, ((Power)result).Watts);
123123
}
124124
}
125125
}

UnitsNet.Serialization.JsonNet.Tests/UnitsNetIQuantityJsonConverterTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public void UnitsNetIQuantityJsonConverter_ReadJson_works_as_expected()
135135

136136
Assert.NotNull(result);
137137
Assert.IsType<Power>(result);
138-
Assert.Equal(10.3654M, ((Power)result).Watts);
138+
Assert.Equal(10.3654, ((Power)result).Watts);
139139
}
140140
}
141141
}

UnitsNet.Tests/CustomCode/MassFlowTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public void TimeSpanTimesMassFlowEqualsMass()
108108
public void MassFlowDividedByBrakeSpecificFuelConsumptionEqualsPower()
109109
{
110110
Power power = MassFlow.FromTonnesPerDay(20) / BrakeSpecificFuelConsumption.FromGramsPerKiloWattHour(180.0);
111-
AssertEx.EqualTolerance(20.0m / 24.0m * 1e6m / 180.0m, power.Kilowatts, 1E-11m);
111+
AssertEx.EqualTolerance(20.0 / 24.0 * 1e6 / 180.0, power.Kilowatts, 1e-11);
112112
}
113113

114114
[Fact]

UnitsNet.Tests/CustomCode/PowerRatioTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ public void ExpectPowerConvertedCorrectly(double power, double expected)
5555
public void ExpectPowerRatioConvertedCorrectly(double powerRatio, double expected)
5656
{
5757
PowerRatio pr = PowerRatio.FromDecibelWatts(powerRatio);
58-
decimal actual = pr.ToPower().Watts;
59-
Assert.Equal((decimal)expected, actual);
58+
var actual = pr.ToPower().Watts;
59+
Assert.Equal(expected, actual);
6060
}
6161

6262
// http://www.maximintegrated.com/en/app-notes/index.mvp/id/808

UnitsNet.Tests/CustomCode/PowerTests.cs

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,57 +9,58 @@ namespace UnitsNet.Tests
99
public class PowerTests : PowerTestsBase
1010
{
1111
protected override bool SupportsSIUnitSystem => false;
12-
protected override decimal FemtowattsInOneWatt => 1e15m;
1312

14-
protected override decimal GigajoulesPerHourInOneWatt => 3600e-9m;
13+
protected override double FemtowattsInOneWatt => 1e15;
1514

16-
protected override decimal PicowattsInOneWatt => 1e12m;
15+
protected override double GigajoulesPerHourInOneWatt => 3600e-9;
1716

18-
protected override decimal NanowattsInOneWatt => 1e9m;
17+
protected override double PicowattsInOneWatt => 1e12;
1918

20-
protected override decimal MicrowattsInOneWatt => 1e6m;
19+
protected override double NanowattsInOneWatt => 1e9;
2120

22-
protected override decimal MillijoulesPerHourInOneWatt => 3600e3m;
21+
protected override double MicrowattsInOneWatt => 1e6;
2322

24-
protected override decimal MilliwattsInOneWatt => 1e3m;
23+
protected override double MillijoulesPerHourInOneWatt => 3600e3;
2524

26-
protected override decimal DeciwattsInOneWatt => 1e1m;
25+
protected override double MilliwattsInOneWatt => 1e3;
2726

28-
protected override decimal WattsInOneWatt => 1;
27+
protected override double DeciwattsInOneWatt => 1e1;
2928

30-
protected override decimal DecawattsInOneWatt => 1e-1m;
29+
protected override double WattsInOneWatt => 1;
3130

32-
protected override decimal KilojoulesPerHourInOneWatt => 3600e-3m;
31+
protected override double DecawattsInOneWatt => 1e-1;
3332

34-
protected override decimal KilowattsInOneWatt => 1e-3m;
33+
protected override double KilojoulesPerHourInOneWatt => 3600e-3;
3534

36-
protected override decimal MegajoulesPerHourInOneWatt => 3600e-6m;
35+
protected override double KilowattsInOneWatt => 1e-3;
3736

38-
protected override decimal MegawattsInOneWatt => 1e-6m;
37+
protected override double MegajoulesPerHourInOneWatt => 3600e-6;
3938

40-
protected override decimal GigawattsInOneWatt => 1e-9m;
39+
protected override double MegawattsInOneWatt => 1e-6;
4140

42-
protected override decimal TerawattsInOneWatt => 1e-12m;
41+
protected override double GigawattsInOneWatt => 1e-9;
4342

44-
protected override decimal PetawattsInOneWatt => 1e-15m;
43+
protected override double TerawattsInOneWatt => 1e-12;
4544

46-
protected override decimal JoulesPerHourInOneWatt => 3600;
45+
protected override double PetawattsInOneWatt => 1e-15;
4746

48-
protected override decimal KilobritishThermalUnitsPerHourInOneWatt => 3.412141633e-3m;
47+
protected override double JoulesPerHourInOneWatt => 3600;
4948

50-
protected override decimal BoilerHorsepowerInOneWatt => 1.0191082802547770700636942675159e-4m;
49+
protected override double KilobritishThermalUnitsPerHourInOneWatt => 3.412141633e-3;
5150

52-
protected override decimal MegabritishThermalUnitsPerHourInOneWatt => 3.412141633e-6m;
51+
protected override double BoilerHorsepowerInOneWatt => 1.0191082802547770700636942675159e-4;
5352

54-
protected override decimal BritishThermalUnitsPerHourInOneWatt => 3.412141633m;
53+
protected override double MegabritishThermalUnitsPerHourInOneWatt => 3.412141633e-6;
5554

56-
protected override decimal ElectricalHorsepowerInOneWatt => 0.00134048257372654155495978552279m;
55+
protected override double BritishThermalUnitsPerHourInOneWatt => 3.412141633;
5756

58-
protected override decimal HydraulicHorsepowerInOneWatt => 0.00134102207184949258114167291719m;
57+
protected override double ElectricalHorsepowerInOneWatt => 0.00134048257372654155495978552279;
5958

60-
protected override decimal MechanicalHorsepowerInOneWatt => 0.00134103984229371454625916935992m;
59+
protected override double HydraulicHorsepowerInOneWatt => 0.00134102207184949258114167291719;
6160

62-
protected override decimal MetricHorsepowerInOneWatt => 0.00135962161730390432342679032425m;
61+
protected override double MechanicalHorsepowerInOneWatt => 0.00134103984229371454625916935992;
62+
63+
protected override double MetricHorsepowerInOneWatt => 0.00135962161730390432342679032425;
6364

6465
[Fact]
6566
public void DurationTimesPowerEqualsEnergy()

UnitsNet.Tests/CustomCode/SpecificEnergyTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public void DoubleDividedBySpecificEnergyEqualsBrakeSpecificFuelConsumption()
7171
public void SpecificEnergyTimesMassFlowEqualsPower()
7272
{
7373
Power power = SpecificEnergy.FromJoulesPerKilogram(10.0) * MassFlow.FromKilogramsPerSecond(20.0);
74-
Assert.Equal(200m, power.Watts);
74+
Assert.Equal(200, power.Watts);
7575
}
7676

7777
[Fact]

UnitsNet.Tests/DecimalOverloadTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public static void CreatingQuantityWithDoubleBackingFieldFromDecimalReturnsCorre
1818
public static void CreatingQuantityWithDecimalBackingFieldFromDecimalReturnsCorrectValue()
1919
{
2020
Power power = Power.FromWatts(1m);
21-
Assert.Equal(1.0m, power.Watts);
21+
Assert.Equal(1.0, power.Watts);
2222
}
2323
}
2424
}

0 commit comments

Comments
 (0)