Subject: Re: [boost] [units] Pull request and RFC: information unit definitions for Boost.Units
From: Erik Erlandson (eje_at_[hidden])
Date: 2014-06-20 12:17:00


----- Original Message -----
> Link to PR: https://github.com/boostorg/units/pull/3
>
> Description:
> Adds unit definitions for standard units of information: bit, byte, nat,
> hartley, shannon. Defines a new unit system boost::units::information for
> convenient manipulation. Also includes IEC binary prefixes: kibi, mebi,
> gibi, tebi, pebi, exbi
>
> Example code:
> https://github.com/erikerlandson/units/blob/info_units/example/information.cpp
>
> Unit testing code:
> https://github.com/erikerlandson/units/blob/info_units/test/test_information_units.cpp

In the interest of describing a use case, the reason I found myself wanting this was that for my ongoing edit_distance() project, I want to allow a user to specify a memory limit for the computation. Boost.Units is a nice vehicle for that, since it allows a user to:

(a) specify a memory limit in whatever units and scale they choose, e.g. (10 * si::mega * bytes) or (1 * si::giga * bytes), etc.
(b) be unambiguous that it is a quantity of memory, as opposed to some generic numeric value.

Contrast with typical solutions that say things like "supply an integer that represents the memory limit, in megabytes"

I also intend to support time limits on the computation, and so by the same logic my plan is to allow the user to supply a time limit using a Boost.Units time quantity, in any supported unit based on time_dimension.

Obviously, units of information could support other kinds of use, e.g. applying units to entropies, as in the example code.