Re: [boost] Boost Units library preview

-----Original Message----- From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of Andy Little Sent: Thursday, August 17, 2006 3:50 PM To: boost@lists.boost.org Subject: Re: [boost] Boost Units library preview
...
----------- output:
E:\projects\Test>testgcc quan qft.numeric_value() = 3 boost.units ft1.value() = 3 assertion "f1.value() == 3" failed: file "test.cpp", line 17 6 [sig] testgcc 3984 open_stackdumpfile: Dumping stack trace to testgcc.ex e.stackdump 33204 [sig] testgcc 3984 E:\projects\Test\testgcc.exe: *** fatal error - E:\pr ojects\Test\testgcc.exe: *** called with threadlist_ix -1
In the Units library, the default value type is (currently) double and the semantics of all arithmetic operations are based on this built-in type. No assumptions are made about semantics, only that the required operations exist for ValueType. What is the default value type in Quan? I'm guessing it has something to do with a united value or some other manipulation of value semantics within Quan? Also be careful of literal values and promotions. 3 is an integer, 3.0 is a double, 3L is a long, 3LL is a long long, etc. Eric.

"Eric Lemings" <lemings@roguewave.com> wrote in message
In the Units library, the default value type is (currently) double and the semantics of all arithmetic operations are based on this built-in type. No assumptions are made about semantics, only that the required operations exist for ValueType.
What is the default value type in Quan? I'm guessing it has something to do with a united value or some other manipulation of value semantics within Quan?
You can choose the value_type : #include <quan/length.hpp> ///////NEW!! //only available in the two_param-branch CVS version of Quan #include <boost/numeric/interval.hpp> #include <quan_matters/test/utility/boost_interval.hpp> #include <boost/numeric/interval/io.hpp> ////////////////// #include <iostream> #include <cassert> #include <boost/typeof/typeof.hpp> #include <boost/type_traits/is_same.hpp> int main() { std::cout.precision(32); quan::length::ft qft(3.0); std::cout << "quan qft.numeric_value() = "<< qft.numeric_value() << '\n'; assert((boost::is_same<BOOST_TYPEOF(qft.numeric_value()),double>::value)); assert(qft.numeric_value() ==3.0); quan::length_<float>::ft qft1(3.0f); std::cout << "quan qft1.numeric_value() = "<< qft1.numeric_value() << '\n'; assert( (boost::is_same<BOOST_TYPEOF(qft1.numeric_value()),float>::value)); assert(qft1.numeric_value() ==3.0f); quan::length_<int>::ft qft2(3); std::cout << "quan qft2.numeric_value() = "<< qft2.numeric_value() << '\n'; assert((boost::is_same<BOOST_TYPEOF(qft2.numeric_value()),int>::value)); assert(qft2.numeric_value() ==3); quan::length_<long>::ft qft3(3L); std::cout << "quan qft3.numeric_value() = "<< qft3.numeric_value() << '\n'; assert((boost::is_same<BOOST_TYPEOF(qft3.numeric_value()),long>::value)); assert(qft3.numeric_value() ==3L); quan::length_<unsigned long>::ft qft4(3UL); std::cout << "quan qft4.numeric_value() = "<< qft4.numeric_value() << '\n'; assert((boost::is_same<BOOST_TYPEOF(qft4.numeric_value()),unsigned long>::value)); assert(qft4.numeric_value() ==3UL); quan::length_<signed char>::ft qft5('3'); std::cout << "quan qft5.numeric_value() = "<< qft5.numeric_value() << '\n'; assert((boost::is_same<BOOST_TYPEOF(qft5.numeric_value()),signed char>::value)); assert(qft5.numeric_value() == '3'); quan::length_<unsigned char>::ft qft6('3'); std::cout << "quan qft6.numeric_value() = "<< qft6.numeric_value() << '\n'; assert((boost::is_same<BOOST_TYPEOF(qft6.numeric_value()),unsigned char>::value)); assert(qft6.numeric_value() == '3'); quan::length_<bool>::ft qft7(true); std::cout << "quan qft7.numeric_value() = " << std::boolalpha << qft7.numeric_value() << '\n'; assert((boost::is_same<BOOST_TYPEOF(qft7.numeric_value()),bool>::value)); assert(qft7.numeric_value() == true); //only available in the two_param-branch CVS version of Quan quan::length_<boost::numeric::interval<double> >::ft qft8(boost::numeric::interval<double> (3.)); std::cout << "quan qft8.numeric_value() = " << qft8.numeric_value() <<'\n'; assert((boost::is_same<BOOST_TYPEOF(qft8.numeric_value()),boost::numeric::interval<double>
::value)); assert((qft8.numeric_value() == boost::numeric::interval<double> (3.))); // } output:
E:\projects\Test>testgcc quan qft.numeric_value() = 3 quan qft1.numeric_value() = 3 quan qft2.numeric_value() = 3 quan qft3.numeric_value() = 3 quan qft4.numeric_value() = 3 quan qft5.numeric_value() = 3 quan qft6.numeric_value() = 3 quan qft7.numeric_value() = true quan qft8.numeric_value() = [3,3] E:\projects\Test> ---------------------- regards Andy Little
participants (2)
-
Andy Little
-
Eric Lemings