Skip to content

Commit 5ea0939

Browse files
authored
Decompose unit conversion functions to exact coefficients (non-breaking) (#1498)
This is a port of #1393, targeting the `release-v6` consisting of the changes that didn't require any modifications to the tests. I'll create another PR with the rest of the (breaking) changes in a bit.
1 parent 3a106ac commit 5ea0939

File tree

136 files changed

+1827
-1299
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

136 files changed

+1827
-1299
lines changed

Common/UnitDefinitions/Acceleration.json

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,14 @@
7575
"L": "NauticalMile",
7676
"T": "Second"
7777
},
78-
"FromUnitToBaseFunc": "{x} * 0.5144444444444",
79-
"FromBaseToUnitFunc": "{x} / 0.5144444444444",
78+
"FromUnitToBaseFunc": "{x} * (1852.0 / 3600.0)",
79+
"FromBaseToUnitFunc": "{x} / (1852.0 / 3600.0)",
8080
"Localization": [
8181
{
8282
"Culture": "en-US",
8383
"Abbreviations": [ "kn/s" ]
8484
},
85-
{
85+
{
8686
"Culture": "ru-RU",
8787
"Abbreviations": [ "узел/с" ]
8888
}
@@ -95,14 +95,16 @@
9595
"L": "NauticalMile",
9696
"T": "Minute"
9797
},
98-
"FromUnitToBaseFunc": "{x} * 0.5144444444444 / 60",
99-
"FromBaseToUnitFunc": "{x} / 0.5144444444444 * 60",
98+
"XmlDocSummary": "The knot (/nɒt/) is a unit of speed equal to one nautical mile per hour, exactly 1.852 km/h (approximately 1.151 mph or 0.514 m/s).",
99+
"XmlDocRemarks": "https://en.wikipedia.org/wiki/Knot_(unit)",
100+
"FromUnitToBaseFunc": "{x} * (1852.0 / 3600.0) / 60",
101+
"FromBaseToUnitFunc": "{x} * 60 / (1852.0 / 3600.0)",
100102
"Localization": [
101103
{
102104
"Culture": "en-US",
103105
"Abbreviations": [ "kn/min" ]
104106
},
105-
{
107+
{
106108
"Culture": "ru-RU",
107109
"Abbreviations": [ "узел/мин" ]
108110
}
@@ -115,14 +117,16 @@
115117
"L": "NauticalMile",
116118
"T": "Hour"
117119
},
118-
"FromUnitToBaseFunc": "{x} * 0.5144444444444 / 3600",
119-
"FromBaseToUnitFunc": "{x} / 0.5144444444444 * 3600",
120+
"XmlDocSummary": "The knot (/nɒt/) is a unit of speed equal to one nautical mile per hour, exactly 1.852 km/h (approximately 1.151 mph or 0.514 m/s).",
121+
"XmlDocRemarks": "https://en.wikipedia.org/wiki/Knot_(unit)",
122+
"FromUnitToBaseFunc": "{x} * (1852.0 / 3600.0) / 3600",
123+
"FromBaseToUnitFunc": "{x} * 3600 / (1852.0 / 3600.0)",
120124
"Localization": [
121125
{
122126
"Culture": "en-US",
123127
"Abbreviations": [ "kn/h" ]
124128
},
125-
{
129+
{
126130
"Culture": "ru-RU",
127131
"Abbreviations": [ "узел/час" ]
128132
}

Common/UnitDefinitions/AreaMomentOfInertia.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@
7272
"BaseUnits": {
7373
"L": "Foot"
7474
},
75-
"FromUnitToBaseFunc": "{x} * Math.Pow(0.3048, 4)",
76-
"FromBaseToUnitFunc": "{x} / Math.Pow(0.3048, 4)",
75+
"FromUnitToBaseFunc": "{x} * 0.0086309748412416",
76+
"FromBaseToUnitFunc": "{x} / 0.0086309748412416",
7777
"Localization": [
7878
{
7979
"Culture": "en-US",
@@ -87,8 +87,8 @@
8787
"BaseUnits": {
8888
"L": "Inch"
8989
},
90-
"FromUnitToBaseFunc": "{x} * Math.Pow(2.54e-2, 4)",
91-
"FromBaseToUnitFunc": "{x} / Math.Pow(2.54e-2, 4)",
90+
"FromUnitToBaseFunc": "{x} * 0.0000004162314256",
91+
"FromBaseToUnitFunc": "{x} / 0.0000004162314256",
9292
"Localization": [
9393
{
9494
"Culture": "en-US",

Common/UnitDefinitions/BrakeSpecificFuelConsumption.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@
3838
{
3939
"SingularName": "PoundPerMechanicalHorsepowerHour",
4040
"PluralName": "PoundsPerMechanicalHorsepowerHour",
41-
"FromUnitToBaseFunc": "{x} * 1.689659410672e-7",
42-
"FromBaseToUnitFunc": "{x} / 1.689659410672e-7",
41+
"FromUnitToBaseFunc": "{x} * (0.45359237 / (76.0402249 * 9.80665))/3600",
42+
"FromBaseToUnitFunc": "{x} * 3600 / (0.45359237 / (76.0402249 * 9.80665))",
4343
"XmlDocSummary": "The pound per horse power hour uses mechanical horse power and the imperial pound",
4444
"Localization": [
4545
{

Common/UnitDefinitions/Density.json

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@
7070
"L": "Inch",
7171
"M": "Pound"
7272
},
73-
"FromUnitToBaseFunc": "{x} / 3.6127298147753e-5",
74-
"FromBaseToUnitFunc": "{x} * 3.6127298147753e-5",
73+
"FromUnitToBaseFunc": "{x} * 0.45359237 / 1.6387064e-5",
74+
"FromBaseToUnitFunc": "{x} * 1.6387064e-5 / 0.45359237",
7575
"Prefixes": [ "Kilo" ],
7676
"Localization": [
7777
{
@@ -88,8 +88,8 @@
8888
"L": "Foot",
8989
"M": "Pound"
9090
},
91-
"FromUnitToBaseFunc": "{x} / 0.062427961",
92-
"FromBaseToUnitFunc": "{x} * 0.062427961",
91+
"FromUnitToBaseFunc": "{x} * 0.45359237 / 0.028316846592",
92+
"FromBaseToUnitFunc": "{x} * 0.028316846592 / 0.45359237",
9393
"Prefixes": [ "Kilo" ],
9494
"Localization": [
9595
{
@@ -102,13 +102,13 @@
102102
{
103103
"SingularName": "PoundPerCubicYard",
104104
"PluralName": "PoundsPerCubicYard",
105-
"XmlDocSummary": "Calculated from the definition of <a href=\"https://en.wikipedia.org/wiki/Pound_(mass)\">pound</a> and <a href=\"https://en.wikipedia.org/wiki/Yard\">yard</a> compared to metric kilogram and meter.",
105+
"XmlDocSummary": "Calculated from the definition of <a href=\"https://en.wikipedia.org/wiki/Pound_(mass)\">pound</a> and <a href=\"https://en.wikipedia.org/wiki/Cubic_yard\">Cubic yard</a> compared to metric kilogram and meter.",
106106
"BaseUnits": {
107107
"L": "Yard",
108108
"M": "Pound"
109109
},
110-
"FromUnitToBaseFunc": "{x} * (0.45359237 / 0.9144 / 0.9144 / 0.9144)",
111-
"FromBaseToUnitFunc": "{x} / (0.45359237 / 0.9144 / 0.9144 / 0.9144)",
110+
"FromUnitToBaseFunc": "{x} * 0.45359237 / 0.764554857984",
111+
"FromBaseToUnitFunc": "{x} * 0.764554857984 / 0.45359237",
112112
"Prefixes": [ "Kilo" ],
113113
"Localization": [
114114
{
@@ -173,8 +173,8 @@
173173
"L": "Foot",
174174
"M": "Slug"
175175
},
176-
"FromUnitToBaseFunc": "{x} * 515.378818",
177-
"FromBaseToUnitFunc": "{x} * 0.00194032033",
176+
"FromUnitToBaseFunc": "{x} * (0.45359237 * 9.80665) / (0.3048 * 0.028316846592)",
177+
"FromBaseToUnitFunc": "{x} * (0.3048 * 0.028316846592) / (0.45359237 * 9.80665)",
178178
"Localization": [
179179
{
180180
"Culture": "en-US",
@@ -232,8 +232,8 @@
232232
{
233233
"SingularName": "PoundPerUSGallon",
234234
"PluralName": "PoundsPerUSGallon",
235-
"FromUnitToBaseFunc": "{x} * 1.19826427e2",
236-
"FromBaseToUnitFunc": "{x} / 1.19826427e2",
235+
"FromUnitToBaseFunc": "{x} * 0.45359237 / 0.003785411784",
236+
"FromBaseToUnitFunc": "{x} * 0.003785411784 / 0.45359237",
237237
"Localization": [
238238
{
239239
"Culture": "en-US",
@@ -244,8 +244,8 @@
244244
{
245245
"SingularName": "PoundPerImperialGallon",
246246
"PluralName": "PoundsPerImperialGallon",
247-
"FromUnitToBaseFunc": "{x} * 9.9776398e1",
248-
"FromBaseToUnitFunc": "{x} / 9.9776398e1",
247+
"FromUnitToBaseFunc": "{x} * 0.45359237 / 0.00454609",
248+
"FromBaseToUnitFunc": "{x} * 0.00454609 / 0.45359237",
249249
"Localization": [
250250
{
251251
"Culture": "en-US",
@@ -276,8 +276,8 @@
276276
"L": "Foot",
277277
"M": "Tonne"
278278
},
279-
"FromUnitToBaseFunc": "{x} * 3.53146667214886e4",
280-
"FromBaseToUnitFunc": "{x} / 3.53146667214886e4",
279+
"FromUnitToBaseFunc": "{x} * 1000 / 0.028316846592",
280+
"FromBaseToUnitFunc": "{x} * 0.028316846592 / 1000",
281281
"Localization": [
282282
{
283283
"Culture": "en-US",
@@ -292,8 +292,8 @@
292292
"L": "Inch",
293293
"M": "Tonne"
294294
},
295-
"FromUnitToBaseFunc": "{x} * 6.10237440947323e7",
296-
"FromBaseToUnitFunc": "{x} / 6.10237440947323e7",
295+
"FromUnitToBaseFunc": "{x} * 1000 / 1.6387064e-5",
296+
"FromBaseToUnitFunc": "{x} * 1.6387064e-5 / 1000",
297297
"Localization": [
298298
{
299299
"Culture": "en-US",
@@ -308,8 +308,8 @@
308308
"L": "Foot",
309309
"M": "Gram"
310310
},
311-
"FromUnitToBaseFunc": "{x} * 0.0353146667214886",
312-
"FromBaseToUnitFunc": "{x} / 0.0353146667214886",
311+
"FromUnitToBaseFunc": "{x} * 0.001 / 0.028316846592",
312+
"FromBaseToUnitFunc": "{x} * 0.028316846592 / 0.001",
313313
"Localization": [
314314
{
315315
"Culture": "en-US",
@@ -324,8 +324,8 @@
324324
"L": "Inch",
325325
"M": "Gram"
326326
},
327-
"FromUnitToBaseFunc": "{x} * 61.0237440947323",
328-
"FromBaseToUnitFunc": "{x} / 61.0237440947323",
327+
"FromUnitToBaseFunc": "{x} * 0.001 / 1.6387064e-5",
328+
"FromBaseToUnitFunc": "{x} * 1.6387064e-5 / 0.001",
329329
"Localization": [
330330
{
331331
"Culture": "en-US",
@@ -340,8 +340,8 @@
340340
"L": "Meter",
341341
"M": "Pound"
342342
},
343-
"FromUnitToBaseFunc": "{x} / 2.204622621848775",
344-
"FromBaseToUnitFunc": "{x} * 2.204622621848775",
343+
"FromUnitToBaseFunc": "{x} * 0.45359237",
344+
"FromBaseToUnitFunc": "{x} / 0.45359237",
345345
"Localization": [
346346
{
347347
"Culture": "en-US",
@@ -356,8 +356,8 @@
356356
"L": "Centimeter",
357357
"M": "Pound"
358358
},
359-
"FromUnitToBaseFunc": "{x} / 2.204622621848775e-6",
360-
"FromBaseToUnitFunc": "{x} * 2.204622621848775e-6",
359+
"FromUnitToBaseFunc": "{x} * 0.45359237e6",
360+
"FromBaseToUnitFunc": "{x} / 0.45359237e6",
361361
"Localization": [
362362
{
363363
"Culture": "en-US",
@@ -372,8 +372,8 @@
372372
"L": "Millimeter",
373373
"M": "Pound"
374374
},
375-
"FromUnitToBaseFunc": "{x} / 2.204622621848775e-9",
376-
"FromBaseToUnitFunc": "{x} * 2.204622621848775e-9",
375+
"FromUnitToBaseFunc": "{x} * 0.45359237e9",
376+
"FromBaseToUnitFunc": "{x} / 0.45359237e9",
377377
"Localization": [
378378
{
379379
"Culture": "en-US",
@@ -388,8 +388,8 @@
388388
"L": "Meter",
389389
"M": "Slug"
390390
},
391-
"FromUnitToBaseFunc": "{x} * 14.5939",
392-
"FromBaseToUnitFunc": "{x} / 14.5939",
391+
"FromUnitToBaseFunc": "{x} * 0.45359237 * 9.80665 / 0.3048",
392+
"FromBaseToUnitFunc": "{x} * 0.3048 / (0.45359237 * 9.80665)",
393393
"Localization": [
394394
{
395395
"Culture": "en-US",
@@ -404,8 +404,8 @@
404404
"L": "Centimeter",
405405
"M": "Slug"
406406
},
407-
"FromUnitToBaseFunc": "{x} * 14593903",
408-
"FromBaseToUnitFunc": "{x} / 14593903",
407+
"FromUnitToBaseFunc": "{x} * 0.45359237e6 * 9.80665 / 0.3048",
408+
"FromBaseToUnitFunc": "{x} * 0.3048 / (0.45359237e6 * 9.80665)",
409409
"Localization": [
410410
{
411411
"Culture": "en-US",
@@ -420,8 +420,8 @@
420420
"L": "Millimeter",
421421
"M": "Slug"
422422
},
423-
"FromUnitToBaseFunc": "{x} * 14593903000",
424-
"FromBaseToUnitFunc": "{x} / 14593903000",
423+
"FromUnitToBaseFunc": "{x} * 0.45359237e9 * 9.80665 / 0.3048",
424+
"FromBaseToUnitFunc": "{x} * 0.3048 / (0.45359237e9 * 9.80665)",
425425
"Localization": [
426426
{
427427
"Culture": "en-US",
@@ -436,8 +436,8 @@
436436
"L": "Inch",
437437
"M": "Slug"
438438
},
439-
"FromUnitToBaseFunc": "{x} * 890574.60201535",
440-
"FromBaseToUnitFunc": "{x} / 890574.60201535",
439+
"FromUnitToBaseFunc": "{x} * (0.45359237 * 9.80665) / (0.3048 * 1.6387064e-5)",
440+
"FromBaseToUnitFunc": "{x} * (0.3048 * 1.6387064e-5) / (0.45359237 * 9.80665)",
441441
"Localization": [
442442
{
443443
"Culture": "en-US",

Common/UnitDefinitions/DynamicViscosity.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@
5555
{
5656
"SingularName": "Reyn",
5757
"PluralName": "Reyns",
58-
"FromUnitToBaseFunc": "{x} * 6.8947572931683613e3",
59-
"FromBaseToUnitFunc": "{x} / 6.8947572931683613e3",
58+
"FromUnitToBaseFunc": "{x} * 4.4482216152605 / 0.00064516",
59+
"FromBaseToUnitFunc": "{x} * 0.00064516 / 4.4482216152605",
6060
"Localization": [
6161
{
6262
"Culture": "en-US",
@@ -67,8 +67,8 @@
6767
{
6868
"SingularName": "PoundForceSecondPerSquareInch",
6969
"PluralName": "PoundsForceSecondPerSquareInch",
70-
"FromUnitToBaseFunc": "{x} * 6.8947572931683613e3",
71-
"FromBaseToUnitFunc": "{x} / 6.8947572931683613e3",
70+
"FromUnitToBaseFunc": "{x} * 4.4482216152605 / 0.00064516",
71+
"FromBaseToUnitFunc": "{x} * 0.00064516 / 4.4482216152605",
7272
"Localization": [
7373
{
7474
"Culture": "en-US",
@@ -79,8 +79,8 @@
7979
{
8080
"SingularName": "PoundForceSecondPerSquareFoot",
8181
"PluralName": "PoundsForceSecondPerSquareFoot",
82-
"FromUnitToBaseFunc": "{x} * 4.7880258980335843e1",
83-
"FromBaseToUnitFunc": "{x} / 4.7880258980335843e1",
82+
"FromUnitToBaseFunc": "{x} * 4.4482216152605 / 9.290304e-2",
83+
"FromBaseToUnitFunc": "{x} * 9.290304e-2 / 4.4482216152605",
8484
"Localization": [
8585
{
8686
"Culture": "en-US",
@@ -91,8 +91,8 @@
9191
{
9292
"SingularName": "PoundPerFootSecond",
9393
"PluralName": "PoundsPerFootSecond",
94-
"FromUnitToBaseFunc": "{x} * 1.4881639",
95-
"FromBaseToUnitFunc": "{x} / 1.4881639",
94+
"FromUnitToBaseFunc": "{x} * 0.45359237 / 0.3048",
95+
"FromBaseToUnitFunc": "{x} * 0.3048 / 0.45359237",
9696
"Localization": [
9797
{
9898
"Culture": "en-US",

Common/UnitDefinitions/ElectricConductivity.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
{
3232
"SingularName": "SiemensPerInch",
3333
"PluralName": "SiemensPerInch",
34-
"FromUnitToBaseFunc": "{x} * 3.937007874015748e1",
35-
"FromBaseToUnitFunc": "{x} / 3.937007874015748e1",
34+
"FromUnitToBaseFunc": "{x} / 2.54e-2",
35+
"FromBaseToUnitFunc": "{x} * 2.54e-2",
3636
"Localization": [
3737
{
3838
"Culture": "en-US",
@@ -43,8 +43,8 @@
4343
{
4444
"SingularName": "SiemensPerFoot",
4545
"PluralName": "SiemensPerFoot",
46-
"FromUnitToBaseFunc": "{x} * 3.2808398950131234",
47-
"FromBaseToUnitFunc": "{x} / 3.2808398950131234",
46+
"FromUnitToBaseFunc": "{x} / 0.3048",
47+
"FromBaseToUnitFunc": "{x} * 0.3048",
4848
"Localization": [
4949
{
5050
"Culture": "en-US",

Common/UnitDefinitions/ElectricCurrentDensity.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
"L": "Inch",
3232
"I": "Ampere"
3333
},
34-
"FromUnitToBaseFunc": "{x} * 1.5500031000062000e3",
35-
"FromBaseToUnitFunc": "{x} / 1.5500031000062000e3",
34+
"FromUnitToBaseFunc": "{x} / 0.00064516",
35+
"FromBaseToUnitFunc": "{x} * 0.00064516",
3636
"Localization": [
3737
{
3838
"Culture": "en-US",
@@ -47,8 +47,8 @@
4747
"L": "Foot",
4848
"I": "Ampere"
4949
},
50-
"FromUnitToBaseFunc": "{x} * 1.0763910416709722e1",
51-
"FromBaseToUnitFunc": "{x} / 1.0763910416709722e1",
50+
"FromUnitToBaseFunc": "{x} / 9.290304e-2",
51+
"FromBaseToUnitFunc": "{x} * 9.290304e-2",
5252
"Localization": [
5353
{
5454
"Culture": "en-US",

Common/UnitDefinitions/ElectricSurfaceChargeDensity.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@
5151
"T": "Second",
5252
"I": "Ampere"
5353
},
54-
"FromUnitToBaseFunc": "{x} * 1.5500031000062000e3",
55-
"FromBaseToUnitFunc": "{x} / 1.5500031000062000e3",
54+
"FromUnitToBaseFunc": "{x} / 0.00064516",
55+
"FromBaseToUnitFunc": "{x} * 0.00064516",
5656
"Localization": [
5757
{
5858
"Culture": "en-US",

0 commit comments

Comments
 (0)