-
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -9,6 +9,7 @@ | |||||||||||||||||||
@dimension 𝚯 "𝚯" Temperature # This one is \bfTheta | ||||||||||||||||||||
@dimension 𝐉 "𝐉" Luminosity | ||||||||||||||||||||
@dimension 𝐍 "𝐍" Amount | ||||||||||||||||||||
@dimension 𝐛 "𝐛" Information | ||||||||||||||||||||
const RelativeScaleTemperature = Quantity{T, 𝚯, <:AffineUnits} where T | ||||||||||||||||||||
const AbsoluteScaleTemperature = Quantity{T, 𝚯, <:ScalarUnits} where T | ||||||||||||||||||||
|
||||||||||||||||||||
|
@@ -60,6 +61,7 @@ const AbsoluteScaleTemperature = Quantity{T, 𝚯, <:ScalarUnits} where T | |||||||||||||||||||
@refunit cd "cd" Candela 𝐉 true | ||||||||||||||||||||
@refunit g "g" Gram 𝐌 true | ||||||||||||||||||||
@refunit mol "mol" Mole 𝐍 true | ||||||||||||||||||||
@refunit b "b" Bit 𝐛 false | ||||||||||||||||||||
|
||||||||||||||||||||
# Angles and solid angles | ||||||||||||||||||||
@unit sr "sr" Steradian 1 true | ||||||||||||||||||||
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. This is breaking |
||||||||||||||||||||
|
||||||||||||||||||||
# Volume | ||||||||||||||||||||
# `l` is also an acceptable symbol for liters | ||||||||||||||||||||
|
@@ -216,11 +218,29 @@ const Å = Å = angstrom | |||||||||||||||||||
# Pressure | ||||||||||||||||||||
@unit psi "psi" PoundsPerSquareInch 1lbf/inch^2 false | ||||||||||||||||||||
|
||||||||||||||||||||
# Data | ||||||||||||||||||||
@unit B "B" Byte 8b false | ||||||||||||||||||||
Comment on lines
+221
to
+222
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Suggested change
|
||||||||||||||||||||
# deciBytes can be a problem with deciBels, and we don't actually care about orders < 1 | ||||||||||||||||||||
# Instead define all units in common use | ||||||||||||||||||||
# Overflow warning: | ||||||||||||||||||||
# Gigascale and above likely exceed Int32 | ||||||||||||||||||||
# Exascale likely exceeds Int64 | ||||||||||||||||||||
# Omitting ZB and YB: Julia interprets literal as Float64, which causes rounding errors | ||||||||||||||||||||
@unit kB "kB" KiloByte 8_000b false | ||||||||||||||||||||
@unit MB "MB" MegaByte 8_000_000b false | ||||||||||||||||||||
@unit GB "GB" GigaByte 8_000_000_000b false | ||||||||||||||||||||
Comment on lines
+229
to
+231
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should the base 2 ones also be included?
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||||||||||||||||
@unit TB "TB" TeraByte 8_000_000_000_000b false | ||||||||||||||||||||
@unit PB "PB" PetaByte 8_000_000_000_000_000b false | ||||||||||||||||||||
@unit EB "EB" ExaByte 8_000_000_000_000_000_000b false | ||||||||||||||||||||
# Data rate | ||||||||||||||||||||
@unit bps "bps" BitPerSecond 1b/s true | ||||||||||||||||||||
@unit Bps "Bps" BytePerSecond 8b/s true | ||||||||||||||||||||
|
||||||||||||||||||||
######### | ||||||||||||||||||||
# 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 commentThe reason will be displayed to describe this comment to others. Learn more. And this one as well |
||||||||||||||||||||
@logscale Np "Np" Neper ℯ 1//2 true | ||||||||||||||||||||
@logscale cNp "cNp" Centineper ℯ 50 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.
Should this be a dimension? I thought that
nat
is, likerad
, a pure number -- it's just somep*log(p)
wherep
is a probability. And bits, like degrees etc, are multiples of that.