paholg / dimensioned

Compile-time dimensional analysis for various unit systems using Rust's type system.
https://crates.io/crates/dimensioned
MIT License
299 stars 23 forks source link

Add a dimension of "information" #37

Open nagisa opened 6 years ago

nagisa commented 6 years ago

A basic unit would be a bit.

tismith commented 6 years ago

I just had a play with adding a 'information' system of units, and it can totally work. I defined a basic system with Bits and Seconds, with some constants for MB, MiB etc. This crate and the macros it provides makes that really easy to quickly implement.

However, I'm not sure this crate is the best fit - using floating point as a basis isn't really the right choice for arithmetic involving bits.

paholg commented 6 years ago

I started adding integer support. If you point to GitHub instead of the version on crates, it's there. I haven't pushed it to crates yet as it's not as documented and tested as I would like.

Edit: See this comment for an idea of how to use them.

droundy commented 6 years ago

Floating point could be useful for information if you're doing something like data compression, where you can have non-integer bits per symbol.

DrSensor commented 6 years ago

Also, units pixel, megapixel, and px/inch along with bit, byte, kB, MB, and GB might come in handy to predefined and bundled in system of units "information".

nagisa commented 6 years ago

Pixels are unitless (much like e.g. radians) and you cannot convert between pixels and infirmation without knowledge of bit depth (bits per pixel).

On Fri, Jul 20, 2018, 06:25 Fahmi Akbar Wildana notifications@github.com wrote:

Also, units pixel, megapixel, and px/inch along with bit, byte, kB, MB, and GB might come in handy to predefined and bundled in system of units "information".

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/paholg/dimensioned/issues/37#issuecomment-406478174, or mute the thread https://github.com/notifications/unsubscribe-auth/AApc0tiOnazmeO7GyHwuyZGWQboNTibRks5uIU2OgaJpZM4SsM2m .

wetlife commented 6 years ago

Qbit of some energy? The lowest energy nontrivial qbit would be a bit like a binary digit.