Boost logo

Boost :

From: Paul A Bristow (pbristow_at_[hidden])
Date: 2007-05-07 10:18:47


 

>-----Original Message-----
>From: boost-bounces_at_[hidden]
>[mailto:boost-bounces_at_[hidden]] On Behalf Of Dean Michael Berris
>Sent: 07 May 2007 12:14
>To: boost_at_[hidden]
>Subject: [boost] [HEAD] lexical_cast<int8_t>("127") bug?
>
>Hi Everyone,
>
>I've recently tried the following (inlined test) which isolates the
>problem I've encountered with boost::lexical_cast<int8_t>:
>
>#include <iostream>
>#include <boost/lexical_cast.hpp>
>
>int main(int argc, char * argv[]) {
> int8_t value;
> try {
> value = boost::lexical_cast<int8_t>("127");
> } catch (std::exception & e) {
> std::cerr << e.what() << '\n';
> }
> return 0;
>};
>
>This is compiled with gcc 4.1.2 on Linux. Any idea why 127 wouldn't
>fit into an 8-bit signed integer? The defined range for signed 8 bit
>integers should be -127..+127 right?

I also recollect that I never understood why

   zz = lexical_cast<int>("0xffff"); // Fails!

However I was more concerned about the floating-point problems, now sorted out,
and I didn't waste any brain activity on it.

(This was with MSVC 7 and 8).

Paul

---
Paul A Bristow
Prizet Farmhouse, Kendal, Cumbria UK LA8 8AB
+44 1539561830 & SMS, Mobile +44 7714 330204 & SMS
pbristow_at_[hidden]
 

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk