|
Boost Users : |
From: Vyacheslav E. Andrejev (vandrejev_at_[hidden])
Date: 2005-05-01 00:55:25
Hello All
I tried to use boost numeric conversion library and faced with strange feature
of RoundEven that I can not comprehend or find expanation in the documentation.
First I thought that this policy rounds float number to nearest integer,
because RoundEven::round_style::value == std::round_to_nearest. But! This
policy for example returns 2.0 for 3.0 as argument!
cout << boost::numeric::converter<
int
, double
, boost::numeric::conversion_traits<int, double>
, boost::numeric::silent_overflow_handler
, boost::numeric::RoundEven<double>
>::convert(2.9) << endl;
cout << boost::numeric::converter<
int
, double
, boost::numeric::conversion_traits<int, double>
, boost::numeric::silent_overflow_handler
, boost::numeric::RoundEven<double>
>::convert(3.0) << endl;
cout << boost::numeric::converter<
int
, double
, boost::numeric::conversion_traits<int, double>
, boost::numeric::silent_overflow_handler
, boost::numeric::RoundEven<double>
>::convert(3.1) << endl;
Output of the program above will be:
3
2
3
What is the cause of such strange behaviour? This is a bug or there is something
that I don't understand?
-- Vyacheslav E. Andrejev System Architect, Excelsior, LLC
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net