-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement bit and byte for information and data #419
base: master
Are you sure you want to change the base?
Implement bit and byte for information and data #419
Conversation
Create information. Define Byte as basic unit for data storage. Include data rates. Modify barn (b -> bn) and Bel (B -> bel) to accommodate the new definitions.
Test that manually-added prefixes match expected SI prefixes.
It looks like the Float32 problem is realized on x86. How to proceed? I can leave out SI prefixes and let users decide if they want to declare kB, MB, GB, etc. I don't see any other units doing this, but can I declare e.g. @unit TB "TB" TeraByte 1_000GB false Alternatively I could try to rewrite the @Unit macro such that the input |
@@ -113,7 +115,7 @@ end | |||
# The hectare is used more frequently than any other power-of-ten of an are. | |||
@unit a "a" Are 100m^2 false | |||
const ha = Unitful.FreeUnits{(Unitful.Unit{:Are, 𝐋^2}(2, 1//1),), 𝐋^2}() | |||
@unit b "b" Barn 100fm^2 true | |||
@unit bn "bn" Barn 100fm^2 true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is breaking
######### | ||
# Logarithmic scales and units | ||
|
||
@logscale dB "dB" Decibel 10 10 false | ||
@logscale B "B" Bel 10 1 false | ||
@logscale bel "Bel" Bel 10 1 false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And this one as well
Is backward-compatibility-breaking prohibited? In my field Bel is never used (only decibel), and I don't know how common or significant Barn is, so I assumed bit and Byte were more common definitions of those abbreviations. |
We can have a breaking change, but need to do a breaking release (i.e., go to v2.0), which would cause some friction in the ecosystem of packages relying on Unitful, for little benefit |
I would suggest to use |
@@ -9,6 +9,7 @@ | |||
@dimension 𝚯 "𝚯" Temperature # This one is \bfTheta | |||
@dimension 𝐉 "𝐉" Luminosity | |||
@dimension 𝐍 "𝐍" Amount | |||
@dimension 𝐛 "𝐛" Information |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be a dimension? I thought that nat
is, like rad
, a pure number -- it's just some p*log(p)
where p
is a probability. And bits, like degrees etc, are multiples of that.
@dimension 𝐛 "𝐛" Information |
# Data | ||
@unit B "B" Byte 8b false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the definitions were like this, would it still convert MB to GB as integers, without introducing the log(2)
?
# Data | |
@unit B "B" Byte 8b false | |
# Information | |
@unit nat "nat" Nat 1 false | |
@unit bit "bit" Bit log(2)*u"nat" false | |
@unit B "B" Byte 8bit false |
@unit kB "kB" KiloByte 8_000b false | ||
@unit MB "MB" MegaByte 8_000_000b false | ||
@unit GB "GB" GigaByte 8_000_000_000b false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the base 2 ones also be included?
@unit kB "kB" KiloByte 8_000b false | |
@unit MB "MB" MegaByte 8_000_000b false | |
@unit GB "GB" GigaByte 8_000_000_000b false | |
@unit kB "kB" KiloByte 8_000b false | |
@unit kiB "kiB" KibiByte 8_192b false | |
@unit MB "MB" MegaByte 8_000_000b false | |
@unit MiB "MiB" MebiByte 8_388_608b false | |
@unit GB "GiB" GigaByte 8_000_000_000b false | |
@unit GiB "GiB" GibiByte 8_589_934_592b false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"GiB"
appears twice in the suggested change, looks like a typo.
Regarding the question of adding another dimension for the desired units, I propose to go with dimensionless units, since
|
I was going to say that these points all apply to angles, where radians are also pure numbers. But it turns out they have in fact been blessed by SI. Nevertheless, it is not an accident that storage and information are measured in the same units. There are mistakes you can make which won't be caught by checking the units, but there are also such mistakes when measuring both height and distance in metres. |
I am in need of such a unit in order to handle data rates in networking problems. |
Hope it's not off-topic: there is a relevant package https://github.com/uriele/UnitfulData.jl |
Create information. Define Byte as basic unit for data storage. Include data rates. Modify barn (b -> bn) and Bel (B -> bel) to accommodate the new definitions.
Closes #173.
Mostly addresses #330.
Does not include e.g. methods for converting between bits and entropy, this is probably reasonable since most users will think of bits as data (e.g. storage capacity, transfer rates) rather than information.
Personal preferences:
Quirks:
1Zm/Em == 1000
returnstrue
)I've included tests for the manual SI prefixes.