
Hi Hermann,
Hi,
in my opinion, casting -2147483647 to a float should be raising an exception
numeric_cast<> checks for "range" errors, ie overflow, but not for loose of significant precision. This is like so by design, and AFAICT the documentation is very clear about that. Loose of precision is not checked because (a) it is not trivial to do so *generically* and (b) looseless numeric conversions are less popular (that is, *that* should be a different function as it has a significantly different overhead) Having said that, the *policy* based conversion utility that is used by numeric_cast could be extended with an *additional* precision_check policy (to be called if the range check suceeds) that could be used to implement a "looseless_numeric_cast<>". Do you have a concrete idea about how such a policy could be implemented *generically*? HTH Fernando Cacciola http://scisoft-consulting.com http://fcacciola.50webs.com