Boost logo

Boost :

From: Richard Peters (r.a.peters_at_[hidden])
Date: 2004-05-04 04:50:00


----- Original Message -----
From: "Joel Young" <jdy_at_[hidden]>
>
> This program
<snip>
> produces:
>
> 9
> 1200144722375
> 11
> 21355614624707
>
> as output using
> g++ (GCC) 3.3.2 20031022 (Red Hat Linux 3.3.2-1)
>
> Why?

Because the second output is in octal notation. In the implementation of the
stream operators, I tested the ios flags for hex and dec, and assumed octal
when the other two flags aren't set. It turns out that the library shipped
with gcc doesn't set any flag on std::cerr, so my library assumed octal
output. Replacing cerr with cout in your example shows the difference.
The workaround for this is to replace lines 64-69 of
big_integer/stream_operators.hpp with:

  if (flags & std::ios_base::oct)
    base = 8;
  else if (flags & std::ios_base::hex)
    base = 16;
  else // if (flags & std::ios_base::dec)
    base = 10;

Best regards,

Richard Peters


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