[conversion] RoundEven odd behaviour
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
::convert(2.9) << endl;
cout << boost::numeric::converter<
int
, double
, boost::numeric::conversion_traits
::convert(3.0) << endl;
cout << boost::numeric::converter<
int
, double
, boost::numeric::conversion_traits
::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
"Vyacheslav E. Andrejev"
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!
It is a bug... sorry about that. Fixed in CVS (HEAD) Thank you for the report. Best Fernando Cacciola SciSoft
participants (2)
-
Fernando Cacciola
-
Vyacheslav E. Andrejev