
I am wondering about the use-case of numeric_cast in this sample. unsigned char uchar_max = std::numeric_limits<unsigned char>::max(); char schar_value = 0; try { schar_value = boost::numeric_cast<char>( uchar_max ); } catch ( boost::bad_numeric_cast ) { std::cout << "Overflow occurred..." << std::endl; } When I execute this sample, I don't get the exception. What's the background on this behavior? I'm using gcc 3.3.1. John

From: "Dill, John" <john-dill@uiowa.edu>
I am wondering about the use-case of numeric_cast in this sample.
unsigned char uchar_max = std::numeric_limits<unsigned char>::max(); char schar_value = 0;
try { schar_value = boost::numeric_cast<char>( uchar_max ); } catch ( boost::bad_numeric_cast ) { std::cout << "Overflow occurred..." << std::endl; }
When I execute this sample, I don't get the exception. What's the background on this behavior? I'm using gcc 3.3.1.
Your char is unsigned. -- Rob Stewart stewart@sig.com Software Engineer http://www.sig.com Susquehanna International Group, LLP using std::disclaimer;

"Dill, John" <john-dill@uiowa.edu> writes:
I am wondering about the use-case of numeric_cast in this sample.
unsigned char uchar_max = std::numeric_limits<unsigned char>::max(); char schar_value = 0;
try { schar_value = boost::numeric_cast<char>( uchar_max ); } catch ( boost::bad_numeric_cast ) { std::cout << "Overflow occurred..." << std::endl; }
When I execute this sample, I don't get the exception. What's the background on this behavior? I'm using gcc 3.3.1.
FWIW, there are known problems with numeric_cast, but a numeric conversion library that replaces the existing implementation has been accepted into Boost. We are just waiting for Fernando Cacciola to check it in. Fernando? -- Dave Abrahams Boost Consulting http://www.boost-consulting.com

"David Abrahams" <dave@boost-consulting.com> escribió en el mensaje news:u3c6ywa5w.fsf@boost-consulting.com...
"Dill, John" <john-dill@uiowa.edu> writes:
I am wondering about the use-case of numeric_cast in this sample.
unsigned char uchar_max = std::numeric_limits<unsigned char>::max(); char schar_value = 0;
try { schar_value = boost::numeric_cast<char>( uchar_max ); } catch ( boost::bad_numeric_cast ) { std::cout << "Overflow occurred..." << std::endl; }
When I execute this sample, I don't get the exception. What's the background on this behavior? I'm using gcc 3.3.1.
FWIW, there are known problems with numeric_cast, but a numeric conversion library that replaces the existing implementation has been accepted into Boost. We are just waiting for Fernando Cacciola to check it in. Fernando?
Indeed. The accepted numeric conversions library handles this case properly (throwing). Right now I'm technically on vacation until next Monday. I'll start working with the review comments right next week. I'll check it in on CVS after I made the neccesary changes. Anyway, users can download the review version from here: http://personales.ciudad.com.ar/fernando_cacciola/numeric_conversions.zip or http://groups.yahoo.com/group/boost/files/numeric_conversions.zip Fernando Cacciola SciSoft

Fernando Cacciola wrote:
Anyway, users can download the review version from here:
http://personales.ciudad.com.ar/fernando_cacciola/numeric_conversions.zip
or
http://groups.yahoo.com/group/boost/files/numeric_conversions.zip
I've downloaded both but they seem corrupt or empty !?

"Toon Knapen" <toon.knapen@fft.be> escribió en el mensaje news:408676CF.9070406@fft.be...
Fernando Cacciola wrote:
Anyway, users can download the review version from here:
http://personales.ciudad.com.ar/fernando_cacciola/numeric_conversions.zip
or
http://groups.yahoo.com/group/boost/files/numeric_conversions.zip
I've downloaded both but they seem corrupt or empty !?
Hmm. that's weird. Regarding the copy at the yahoo site (The Files section) the problem might be that yahoo is asking you to sign in so the downloaded file is actually an html. Regarding the copy at my site, I don't know :-) I just downloaded it and it was OK You could try again, or I can sent it t you directly. Best Fernando Cacciola SciSoft

Fernando Cacciola wrote:
"Toon Knapen" <toon.knapen@fft.be> escribió en el mensaje news:408676CF.9070406@fft.be...
Fernando Cacciola wrote:
Anyway, users can download the review version from here:
http://personales.ciudad.com.ar/fernando_cacciola/numeric_conversions.zip
or
http://groups.yahoo.com/group/boost/files/numeric_conversions.zip
I've downloaded both but they seem corrupt or empty !?
Hmm. that's weird.
I tried again (although initially I had tried about 10 times) and it seems to be OK now. Thanks.
participants (5)
-
David Abrahams
-
Dill, John
-
Fernando Cacciola
-
Rob Stewart
-
Toon Knapen