Boost logo

Boost :

From: Daryle Walker (darylew_at_[hidden])
Date: 2004-05-05 00:52:45


On 5/4/04 5:50 AM, "Richard Peters" <r.a.peters_at_[hidden]> wrote:

> ----- 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;

It's probably better to make that a permanent change. I think that
unspecified combination of the base flags is supposed to imply decimal, not
octal! (I looked at the way the locales read/write stuff in the standard
document [1998 version] at section 22.2.2.)

-- 
Daryle Walker
Mac, Internet, and Video Game Junkie
darylew AT hotmail DOT com

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