help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: setbase(2)


From: Rai Hardeep S.
Subject: Re: setbase(2)
Date: 23 Nov 2004 12:02:37 GMT
User-agent: slrn/0.9.7.4 (Linux)

On Sun, 21 Nov 2004 15:16:41 +0100, Ulrich Eckhardt <doomster@knuut.de> wrote:
> Rai Hardeep S. wrote:
>> Is there any equivalent to setbase(2), i.e to take output in binary
>> form. As such setbase() can accept 8, 10 and 16 argument.
> 
> Not GCC specific, but there are (IIRC) overloaded inserters/extractors in
> std::bitset.

Thank you Ulrich Eckha for your code. I know one can write easily
function to achieve the objective.

If I unserstood correctly, the bitset will be something like array
which may store only 0 and 1, and not for directly writing values in
binary form.

>> I wish to take output in binary form.
> 
> I hope you mean that you want numbers to be formatted as sequences of '0'
> and '1' characters, and not some kind of binary as opposed to textual.

Yes, you are right.

Infact, I wonder, why such function is not available in C++,
setbase() function may be made to accept 2 in addition to 8, 10 and
16, or even any other base valve.

Is there any specific reason, not to include base 2 in above
function, and not to provide any othere function for this need.

-- 
H. S. Rai,


reply via email to

[Prev in Thread] Current Thread [Next in Thread]