speed of light from universal_constants Boost.Units

Hi, I've tried and tried and just not understanding or can't muddle my way through the boost units(looks powerful though). For a start, just trying to get at the speed of light in boost/units/systems/si/codata/universal_constants.hpp boost::units::si::constants::codata::c boost::units<boost::units::si>::constants::codata::c.value() and massive errors; especially if I try to multiplying with something. I use boost::math::constants::pi<double>() from #include "boost/math/constants/constants.hpp" But the universals allude me; and example? where is my brain stuck?

AMDG On 03/10/2014 10:12 AM, Roger Martin wrote:
I'm not sure. You'll need to give more details. (preferable a small /complete/ program that doesn't compile) The following seems to work for me. (I did run into the fact that there's a missing #include <boost/units/quantity.hpp> in the constants.) #include <boost/units/quantity.hpp> #include <boost/units/systems/si/codata_constants.hpp> #include <boost/units/io.hpp> #include <iostream> int main() { std::cout << boost::units::si::constants::codata::c * 2.5 << std::endl; } In Christ, Steven Watanabe

On 03/10/2014 01:37 PM, Steven Watanabe wrote:
I got going with what you showed me but learned the multiplication needs casting to long double before the math would work/compile. And division(I'll try more operations). std::cout<< boost::units::si::constants::codata::c * 2.5l<< std::endl; failed for me while std::cout<< boost::units::si::constants::codata::c * 2.5<< std::endl; works.
participants (2)
-
Roger Martin
-
Steven Watanabe