C++ Library Question.
-
The library member, <bitset> allows one to do the following:
cout<('A') <and see the binary representation of "A" displayed.
It doesn't look as though the library offers a means to reverse the transformation, where if you were to give the binary representation, you'd get back the ASCII equivalent.
Does anyone know of such a way?
Thanks for any suggestion.
:)
William
Fortes in fide et opere!
-
The library member, <bitset> allows one to do the following:
cout<('A') <and see the binary representation of "A" displayed.
It doesn't look as though the library offers a means to reverse the transformation, where if you were to give the binary representation, you'd get back the ASCII equivalent.
Does anyone know of such a way?
Thanks for any suggestion.
:)
William
Fortes in fide et opere!
If you begin with a bitset class, you can use bitset::to_ulong and then cast the ulong as a char for display.
-
If you begin with a bitset class, you can use bitset::to_ulong and then cast the ulong as a char for display.
-
The library member, <bitset> allows one to do the following:
cout<('A') <and see the binary representation of "A" displayed.
It doesn't look as though the library offers a means to reverse the transformation, where if you were to give the binary representation, you'd get back the ASCII equivalent.
Does anyone know of such a way?
Thanks for any suggestion.
:)
William
Fortes in fide et opere!
-
Hi, there is a function called
to_ulong()
defined in thebitset
header file which is the counterfunction toto_string()
which turns a string into a binary value. Hope it helps. Regards. AlexThanks for replying. An earlier response has already pointed me in the right direction which wasn't too far from what your suggestion offered. I knew of "to_ulong()" and have used it several times before, but it only seemed to take the binary representation and return its numeric equivalent, not an alphabetic value if the binary representation it was given, were for such a value. Thanks anyway for replying. I appreciate it. :) William Fortes in fide et opere!