Skip to content

Commit cb6454c

Browse files
Improve precision of Mass, Area units (#1190)
Fixes #1188 Use computations where applicable instead of finite constants. Improve constant precision where no calculation is available. --------- Co-authored-by: Tristan Milnthorp <[email protected]>
1 parent 6b61d11 commit cb6454c

File tree

18 files changed

+141
-42
lines changed

18 files changed

+141
-42
lines changed

Common/UnitDefinitions/Area.json

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,10 @@
150150
"BaseUnits": {
151151
"L": "Mile"
152152
},
153-
"FromUnitToBaseFunc": "{x} * 2.59e6",
154-
"FromBaseToUnitFunc": "{x} / 2.59e6",
153+
"FromUnitToBaseFunc": "{x} * 1609.344 * 1609.344",
154+
"FromBaseToUnitFunc": "{x} / 1609.344 / 1609.344",
155+
"XmlDocSummary": "The statute mile was standardised between the British Commonwealth and the United States by an international agreement in 1959, when it was formally redefined with respect to SI units as exactly 1,609.344 metres.",
156+
"XmlDocRemarks": "https://en.wikipedia.org/wiki/Mile",
155157
"Localization": [
156158
{
157159
"Culture": "en-US",
@@ -173,8 +175,10 @@
173175
"BaseUnits": {
174176
"L": "Yard"
175177
},
176-
"FromUnitToBaseFunc": "{x} * 0.836127",
177-
"FromBaseToUnitFunc": "{x} / 0.836127",
178+
"FromUnitToBaseFunc": "{x} * 0.9144 * 0.9144",
179+
"FromBaseToUnitFunc": "{x} / 0.9144 / 0.9144",
180+
"XmlDocSummary": "The yard (symbol: yd) is an English unit of length in both the British imperial and US customary systems of measurement equalling 3 feet (or 36 inches). Since 1959 the yard has been by international agreement standardized as exactly 0.9144 meter. A distance of 1,760 yards is equal to 1 mile.",
181+
"XmlDocRemarks": "https://en.wikipedia.org/wiki/Yard",
178182
"Localization": [
179183
{
180184
"Culture": "en-US",
@@ -219,8 +223,10 @@
219223
"BaseUnits": {
220224
"L": "UsSurveyFoot"
221225
},
222-
"FromUnitToBaseFunc": "{x} * 0.09290341161",
223-
"FromBaseToUnitFunc": "{x} / 0.09290341161",
226+
"FromUnitToBaseFunc": "{x} * (1200.0 / 3937.0) * (1200.0 / 3937.0)",
227+
"FromBaseToUnitFunc": "{x} / (1200.0 / 3937.0) / (1200.0 / 3937.0)",
228+
"XmlDocSummary": "In the United States, the foot was defined as 12 inches, with the inch being defined by the Mendenhall Order of 1893 as 39.37 inches = 1 m. This makes a U.S. survey foot exactly 1200/3937 meters.",
229+
"XmlDocRemarks": "https://en.wikipedia.org/wiki/Foot_(unit)",
224230
"Localization": [
225231
{
226232
"Culture": "en-US",
@@ -258,8 +264,10 @@
258264
{
259265
"SingularName": "Acre",
260266
"PluralName": "Acres",
261-
"FromUnitToBaseFunc": "{x} * 4046.85642",
262-
"FromBaseToUnitFunc": "{x} / 4046.85642",
267+
"FromUnitToBaseFunc": "{x} * 4046.8564224",
268+
"FromBaseToUnitFunc": "{x} / 4046.8564224",
269+
"XmlDocSummary": "Based upon the international yard and pound agreement of 1959, an acre may be declared as exactly 4,046.8564224 square metres.",
270+
"XmlDocRemarks": "https://en.wikipedia.org/wiki/Acre",
263271
"Localization": [
264272
{
265273
"Culture": "en-US",

Common/UnitDefinitions/Length.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
},
3939
"FromUnitToBaseFunc": "{x} * 1609.344",
4040
"FromBaseToUnitFunc": "{x} / 1609.344",
41+
"XmlDocSummary": "The statute mile was standardised between the British Commonwealth and the United States by an international agreement in 1959, when it was formally redefined with respect to SI units as exactly 1,609.344 metres.",
42+
"XmlDocRemarks": "https://en.wikipedia.org/wiki/Mile",
4143
"Localization": [
4244
{
4345
"Culture": "en-US",
@@ -61,6 +63,8 @@
6163
},
6264
"FromUnitToBaseFunc": "{x} * 0.9144",
6365
"FromBaseToUnitFunc": "{x} / 0.9144",
66+
"XmlDocSummary": "The yard (symbol: yd) is an English unit of length in both the British imperial and US customary systems of measurement equalling 3 feet (or 36 inches). Since 1959 the yard has been by international agreement standardized as exactly 0.9144 meter. A distance of 1,760 yards is equal to 1 mile.",
67+
"XmlDocRemarks": "https://en.wikipedia.org/wiki/Yard",
6468
"Localization": [
6569
{
6670
"Culture": "en-US",
@@ -107,6 +111,8 @@
107111
},
108112
"FromUnitToBaseFunc": "{x} * 1200 / 3937",
109113
"FromBaseToUnitFunc": "{x} * 3937 / 1200",
114+
"XmlDocSummary": "In the United States, the foot was defined as 12 inches, with the inch being defined by the Mendenhall Order of 1893 as 39.37 inches = 1 m. This makes a U.S. survey foot exactly 1200/3937 meters.",
115+
"XmlDocRemarks": "https://en.wikipedia.org/wiki/Foot_(unit)",
110116
"Localization": [
111117
{
112118
"Culture": "en-US",

Common/UnitDefinitions/Mass.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@
113113
"FromUnitToBaseFunc": "{x} * 0.45359237",
114114
"FromBaseToUnitFunc": "{x} / 0.45359237",
115115
"XmlDocSummary": "The pound or pound-mass (abbreviations: lb, lbm) is a unit of mass used in the imperial, United States customary and other systems of measurement. A number of different definitions have been used, the most common today being the international avoirdupois pound which is legally defined as exactly 0.45359237 kilograms, and which is divided into 16 avoirdupois ounces.",
116+
"XmlDocRemarks": "https://en.wikipedia.org/wiki/Pound_(mass)",
116117
"Prefixes": [ "Kilo", "Mega" ],
117118
"Localization": [
118119
{
@@ -135,10 +136,10 @@
135136
"BaseUnits": {
136137
"M": "Ounce"
137138
},
138-
"FromUnitToBaseFunc": "{x} / 35.2739619",
139-
"FromBaseToUnitFunc": "{x} * 35.2739619",
140-
"XmlDocSummary": "An ounce (abbreviated oz) is usually the international avoirdupois ounce as used in the United States customary and British imperial systems, which is equal to one-sixteenth of a pound or approximately 28 grams. The abbreviation 'oz' derives from the Italian word onza (now spelled oncia).",
141-
"XmlDocRemarks": "http://en.wikipedia.org/wiki/Ounce",
139+
"FromUnitToBaseFunc": "{x} * 0.028349523125",
140+
"FromBaseToUnitFunc": "{x} / 0.028349523125",
141+
"XmlDocSummary": "The international avoirdupois ounce (abbreviated oz) is defined as exactly 28.349523125 g under the international yard and pound agreement of 1959, signed by the United States and countries of the Commonwealth of Nations. 16 oz make up an avoirdupois pound.",
142+
"XmlDocRemarks": "https://en.wikipedia.org/wiki/Ounce",
142143
"Localization": [
143144
{
144145
"Culture": "en-US",

Common/UnitDefinitions/Speed.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,10 @@
281281
"L": "NauticalMile",
282282
"T": "Hour"
283283
},
284-
"FromUnitToBaseFunc": "{x} * 0.514444",
285-
"FromBaseToUnitFunc": "{x} / 0.514444",
284+
"FromUnitToBaseFunc": "{x} * (1852.0 / 3600.0)",
285+
"FromBaseToUnitFunc": "{x} / (1852.0 / 3600.0)",
286+
"XmlDocSummary": "The knot, by definition, is a unit of speed equals to 1 nautical mile per hour, which is exactly 1852.000 metres per hour. The length of the internationally agreed nautical mile is 1852 m. The US adopted the international definition in 1954, the UK adopted the international nautical mile definition in 1970.",
287+
"XmlDocRemarks": "https://en.wikipedia.org/wiki/Knot_(unit)",
286288
"Localization": [
287289
{
288290
"Culture": "en-US",

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

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

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

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

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

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

UnitsNet.NanoFramework/GeneratedCode/Units/AreaUnit.g.cs

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

UnitsNet.NanoFramework/GeneratedCode/Units/LengthUnit.g.cs

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

UnitsNet.NanoFramework/GeneratedCode/Units/MassUnit.g.cs

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

0 commit comments

Comments
 (0)