Skip to content

Commit

Permalink
Convert BitRate and Information to double (#1353)
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Muximize and angularsen authored Feb 18, 2024
1 parent 943a158 commit aeb0cd7
Show file tree
Hide file tree
Showing 23 changed files with 670 additions and 918 deletions.
5 changes: 2 additions & 3 deletions Common/UnitDefinitions/BitRate.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"Name": "BitRate",
"BaseUnit": "BitPerSecond",
"ValueType": "decimal",
"XmlDocSummary": "In telecommunications and computing, bit rate is the number of bits that are conveyed or processed per unit of time.",
"XmlDocRemarks": "https://en.wikipedia.org/wiki/Bit_rate",
"BaseDimensions": { "T": -1 },
Expand All @@ -22,8 +21,8 @@
{
"SingularName": "BytePerSecond",
"PluralName": "BytesPerSecond",
"FromUnitToBaseFunc": "{x} * 8m",
"FromBaseToUnitFunc": "{x} / 8m",
"FromUnitToBaseFunc": "{x} * 8",
"FromBaseToUnitFunc": "{x} / 8",
"Prefixes": [ "Kilo", "Mega", "Giga", "Tera", "Peta", "Exa", "Kibi", "Mebi", "Gibi", "Tebi", "Pebi", "Exbi" ],
"Localization": [
{
Expand Down
5 changes: 2 additions & 3 deletions Common/UnitDefinitions/Information.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
{
"Name": "Information",
"BaseUnit": "Bit",
"ValueType": "decimal",
"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.",
"Units": [
{
"SingularName": "Byte",
"PluralName": "Bytes",
"FromUnitToBaseFunc": "{x} * 8m",
"FromBaseToUnitFunc": "{x} / 8m",
"FromUnitToBaseFunc": "{x} * 8",
"FromBaseToUnitFunc": "{x} / 8",
"Prefixes": [ "Kilo", "Mega", "Giga", "Tera", "Peta", "Exa", "Kibi", "Mebi", "Gibi", "Tebi", "Pebi", "Exbi" ],
"Localization": [
{
Expand Down
56 changes: 28 additions & 28 deletions UnitsNet.NanoFramework/GeneratedCode/Quantities/BitRate.g.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 28 additions & 28 deletions UnitsNet.NanoFramework/GeneratedCode/Quantities/Information.g.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit aeb0cd7

Please sign in to comment.