"King, William D"
Hello,
I am seeing a bug that the regression tests miss for numeric_cast<unsigned long> with gcc 3.3.2. Specifically, the following code is throwing an exception:
double small_value = 1.25; unsigned long l=0; l = numeric_cast<unsigned long>(small_value); // throws exception! unsinged char c=0; c = numeric_cast<unsigned char>(small_value); // throws exception!
I am under the impression that numeric_cast is supposed to accept losses
of
precision (by truncating the fractional values), and to throw exceptions only if there is a range or sign error. Is this so?
FWIW, the new Numeric Conversions library has recently been accepted into boost. It works exactly as you expected, and has a replacement for numeric_cast<>. Check it out from: http://personales.ciudad.com.ar/fernando_cacciola/numeric_conversions.zip HTH Fernando Cacciola SciSoft