Skip to content
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

New unit system <boost/units/systems/information.hpp> #3

Merged
merged 1 commit into from Oct 10, 2014

Conversation

@erikerlandson
Copy link
Contributor

commented Jun 18, 2014

Defines base units and system units for: bit, byte, nat, hartley and shannon,
and scale units for binary prefixes kibi, mebi, gibi, tebi, pebi, exbi.

Defines base units and system units for: bit, byte, nat, hartley and shannon,
and scale units for binary prefixes kibi, mebi, gibi, tebi, pebi, exbi.
BOOST_UNITS_INFOSYS_PREFIX(30, gibi);
BOOST_UNITS_INFOSYS_PREFIX(40, tebi);
BOOST_UNITS_INFOSYS_PREFIX(50, pebi);
BOOST_UNITS_INFOSYS_PREFIX(60, exbi);

This comment has been minimized.

Copy link
@mkurdej

mkurdej Aug 1, 2014

Member

I would add as well zebi and yobi prefixes for completeness.

BOOST_UNITS_INFOSYS_PREFIX(70, zebi);
BOOST_UNITS_INFOSYS_PREFIX(80, yobi);

quantity<info, long long> q60(1LL * exbi * byte);
BOOST_CHECK_EQUAL(q60.value(), 1152921504606846976LL);

This comment has been minimized.

Copy link
@mkurdej

mkurdej Aug 1, 2014

Member

And for completeness, one should add tests for zebi and yobi prefixes.
Just one problem can arise, because long long int cannot represent numbers greater than 2^63 - 1, so the test can pass with longer integer types only, e.g. int128_t.

#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::int128_t;
// using namespace boost::multiprecision::literals; // necessary if using user-defined literals

quantity<info, int128_t> q70(1LL * zebi * byte);
BOOST_CHECK_EQUAL(q70.value(), int128_t("1180591620717411303424"));
// or equivalent C++11
//BOOST_CHECK_EQUAL(q70.value(), 1180591620717411303424_cppi128);

quantity<info, int128_t> q80(1LL * yobi * byte);
BOOST_CHECK_EQUAL(q80.value(), int128_t("1208925819614629174706176"));
// or equivalent C++11
// BOOST_CHECK_EQUAL(q80.value(), 1208925819614629174706176_cppi128);
@jhunold jhunold self-assigned this Sep 16, 2014
@mkurdej

This comment has been minimized.

Copy link
Member

commented Sep 16, 2014

This pull request can be closed, since #6 has been already merged.

@erikerlandson

This comment has been minimized.

Copy link
Contributor Author

commented Sep 16, 2014

@mkurdej what branch was #3 merged into?

@mkurdej

This comment has been minimized.

Copy link
Member

commented Sep 16, 2014

I was convinced that #6 (containing commit from #3) was merged into develop, but I've checked it again and it's actually a different commit that got merged in #6. I will take a closer look on it.
Sorry for confusion.

@jhunold jhunold merged commit 1932dc7 into boostorg:develop Oct 10, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.