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::unitsboost::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'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::unitsboost::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?
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
On 03/10/2014 01:37 PM, Steven Watanabe wrote:
AMDG
On 03/10/2014 10:12 AM, Roger Martin wrote:
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::unitsboost::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?
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
in the constants.) Ah thank you! I was only using the single header #include or with the #include before it. And I didn't know about the boost/units/io.hpp when cout'ing either. Working in a cunit; I'll make a more complete code example with tests for it and reply again.
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.
#include
#include #include #include<iostream> int main() { std::cout<< boost::units::si::constants::codata::c * 2.5<< std::endl; }
In Christ, Steven Watanabe
_______________________________________________ Unsubscribe& other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
participants (2)
-
Roger Martin
-
Steven Watanabe