From: John Maddock (john_at_[hidden])
Date: 2008-06-03 04:35:02


Tom Brinkman wrote:
>>> Rather than an implementation, could you
>>> provide an example of a documentation, stating precisely what the
>>> return value should be?
>
> Basically, I just want to return the numeric value that is returned
> by sprintf.
>
> Example:
>
> char ch[255];
> sprintf(ch, "%.2f", 333.444);
>
> boost::numeric_cast<double>(ch) == boost::round(333.444,2) == 33.44;

Right, but you can never round exactly to a decimal: for example if you
round 0.1 to one decimal place the result won't be exactly 0.1 (any more
than it was exactly that value to begin with).

John.