Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. C++ Library Question.

C++ Library Question.

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    WREY
    wrote on last edited by
    #1

    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!

    T A 2 Replies Last reply
    0
    • W WREY

      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!

      T Offline
      T Offline
      Terry ONolley
      wrote on last edited by
      #2

      If you begin with a bitset class, you can use bitset::to_ulong and then cast the ulong as a char for display.



      W 1 Reply Last reply
      0
      • T Terry ONolley

        If you begin with a bitset class, you can use bitset::to_ulong and then cast the ulong as a char for display.



        W Offline
        W Offline
        WREY
        wrote on last edited by
        #3

        Thanks for replying. Your suggestion worked very well. Thanks! :) William Fortes in fide et opere!

        1 Reply Last reply
        0
        • W WREY

          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!

          A Offline
          A Offline
          ASchunk
          wrote on last edited by
          #4

          Hi, there is a function called to_ulong() defined in the bitset header file which is the counterfunction to to_string() which turns a string into a binary value. Hope it helps. Regards. Alex

          W 1 Reply Last reply
          0
          • A ASchunk

            Hi, there is a function called to_ulong() defined in the bitset header file which is the counterfunction to to_string() which turns a string into a binary value. Hope it helps. Regards. Alex

            W Offline
            W Offline
            WREY
            wrote on last edited by
            #5

            Thanks 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!

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups