Skip to content

Commit aeb0cd7

Browse files
Muximizeangularsen
andauthored
Convert BitRate and Information to double (#1353)
In PR #1195 @angularsen asks @tmilnthorp: > Question; what do you think of also changing Information/BitRate from decimal to double? > > On one hand, it is sort of weird to risk getting rounding errors like 8.00000001 bits. On the other hand, for all other units (kilobyte, etc) that are probably way more used, floating point is perhaps the expected value representation. > > If we change all 3 quantities to double, we have the potential to clean up a LOT of QuantityValue complexity. How about we continue that discussion here? 😄 This PR is pretty straightforward and mimics #1195, except that `Information` is used as the typical decimal quantity in some tests. Because there won't be any decimal quantities left if these PRs get merged, I removed those tests in anticipation of completely removing all decimal support. --------- Co-authored-by: Andreas Gullberg Larsen <[email protected]>
1 parent 943a158 commit aeb0cd7

23 files changed

+670
-918
lines changed

Common/UnitDefinitions/BitRate.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"Name": "BitRate",
33
"BaseUnit": "BitPerSecond",
4-
"ValueType": "decimal",
54
"XmlDocSummary": "In telecommunications and computing, bit rate is the number of bits that are conveyed or processed per unit of time.",
65
"XmlDocRemarks": "https://en.wikipedia.org/wiki/Bit_rate",
76
"BaseDimensions": { "T": -1 },
@@ -22,8 +21,8 @@
2221
{
2322
"SingularName": "BytePerSecond",
2423
"PluralName": "BytesPerSecond",
25-
"FromUnitToBaseFunc": "{x} * 8m",
26-
"FromBaseToUnitFunc": "{x} / 8m",
24+
"FromUnitToBaseFunc": "{x} * 8",
25+
"FromBaseToUnitFunc": "{x} / 8",
2726
"Prefixes": [ "Kilo", "Mega", "Giga", "Tera", "Peta", "Exa", "Kibi", "Mebi", "Gibi", "Tebi", "Pebi", "Exbi" ],
2827
"Localization": [
2928
{

Common/UnitDefinitions/Information.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
{
22
"Name": "Information",
33
"BaseUnit": "Bit",
4-
"ValueType": "decimal",
54
"XmlDocSummary": "In computing and telecommunications, a unit of information is the capacity of some standard data storage system or communication channel, used to measure the capacities of other systems and channels. In information theory, units of information are also used to measure the information contents or entropy of random variables.",
65
"Units": [
76
{
87
"SingularName": "Byte",
98
"PluralName": "Bytes",
10-
"FromUnitToBaseFunc": "{x} * 8m",
11-
"FromBaseToUnitFunc": "{x} / 8m",
9+
"FromUnitToBaseFunc": "{x} * 8",
10+
"FromBaseToUnitFunc": "{x} / 8",
1211
"Prefixes": [ "Kilo", "Mega", "Giga", "Tera", "Peta", "Exa", "Kibi", "Mebi", "Gibi", "Tebi", "Pebi", "Exbi" ],
1312
"Localization": [
1413
{

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

+28-28
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

+28-28
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)