Boost logo

Boost Users :

Subject: Re: [Boost-users] [numeric::convert] RoundNearest?
From: Diederick C. Niehorster (dcnieho_at_[hidden])
Date: 2011-07-03 06:28:25


Dear All,

And for a related question:
Why is promote used in the example at
http://www.boost.org/doc/libs/1_46_0/libs/type_traits/doc/html/boost_typetraits/examples/to_double.html

Is it somehow advantageous to convert a double to an int if the input
type is float, or likewise to do int to double conversion when the
input type is char?

I hope someone could shed light on the benefits of this.

Thank you!
Best,
Dee

On Sun, Jul 3, 2011 at 18:21, Diederick C. Niehorster <dcnieho_at_[hidden]> wrote:
> Dear All,
>
> I have just discovered Boost.NumericConvert, useful and a nice effort!
> However, I am missing a RoundNearest function for float to int
> conversions, with only RoundEven being provided.
>
> RoundEven of course does exactly what it is described to do, rounding
> .5 to 0 and 1.5 to 2, but i'd like the highschool (usual?) behavior of
> rounding up when a number exactly in the middle is provided. I can
> implement it myself by slightly modifying RoundEven of course, but I
> am wondering if I am missing something obvious or whether there is a
> good reason why this function is not included?
>
> Thank you very much for any thoughts!
>
> Best,
> Dee
>


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