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. cover a double x to char ???

cover a double x to char ???

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
6 Posts 4 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.
  • A Offline
    A Offline
    a04 lqd
    wrote on last edited by
    #1

    example: double 5 cover to '5'.

    L L 2 Replies Last reply
    0
    • A a04 lqd

      example: double 5 cover to '5'.

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      doubles typically don't fit in one char, however you can easily convert them to string. that is so basic, is this your first day at programming? I hope you are wise enough to learn from a book, study it from front to where ever you get, and look at examples and exercises. The exact answer depends on the language you use, which you did not specify. in good old C you could do it with an sprintf() or swprintf() Here[^] is one page of doc, even wikipedia knows how! Please make Google your daily friend. :)

      Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


      I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages


      modified on Friday, December 11, 2009 2:51 PM

      CPalliniC 1 Reply Last reply
      0
      • L Luc Pattyn

        doubles typically don't fit in one char, however you can easily convert them to string. that is so basic, is this your first day at programming? I hope you are wise enough to learn from a book, study it from front to where ever you get, and look at examples and exercises. The exact answer depends on the language you use, which you did not specify. in good old C you could do it with an sprintf() or swprintf() Here[^] is one page of doc, even wikipedia knows how! Please make Google your daily friend. :)

        Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


        I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages


        modified on Friday, December 11, 2009 2:51 PM

        CPalliniC Offline
        CPalliniC Offline
        CPallini
        wrote on last edited by
        #3

        Sorry to say, I think you misunderstood the OP request: he wants to cover the double with a char. This is usually possible, provided the char is by repeated as needed. For instance consider the double 0.75: if you repeat the char '*' four times over it, then you obtain a very good _cover_age. :-D

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
        This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
        [My articles]

        In testa che avete, signor di Ceprano?

        L 1 Reply Last reply
        0
        • CPalliniC CPallini

          Sorry to say, I think you misunderstood the OP request: he wants to cover the double with a char. This is usually possible, provided the char is by repeated as needed. For instance consider the double 0.75: if you repeat the char '*' four times over it, then you obtain a very good _cover_age. :-D

          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
          This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
          [My articles]

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          No problem, Microsoft invented a class[^] for that very purpose. :)

          Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


          I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages


          CPalliniC 1 Reply Last reply
          0
          • L Luc Pattyn

            No problem, Microsoft invented a class[^] for that very purpose. :)

            Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


            I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages


            CPalliniC Offline
            CPalliniC Offline
            CPallini
            wrote on last edited by
            #5

            Nah, (Heretic!) that's for managed development. Furthermore, as usual, they didn't invent it, just stolen it from Java... :-D

            If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
            This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
            [My articles]

            In testa che avete, signor di Ceprano?

            1 Reply Last reply
            0
            • A a04 lqd

              example: double 5 cover to '5'.

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              I guess you probably mean convert; take a look at sprintf[^] and its variants.

              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