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. Convert float to double

Convert float to double

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
5 Posts 5 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
    wow9999
    wrote on last edited by
    #1

    Dear all How to convert float to double? Thanks

    R R 2 Replies Last reply
    0
    • W wow9999

      Dear all How to convert float to double? Thanks

      R Offline
      R Offline
      Rage
      wrote on last edited by
      #2

      Is this not working ?

      float f=1.5f;
      double d;
      d=(double)f;

      ~RaGE();

      R J 2 Replies Last reply
      0
      • R Rage

        Is this not working ?

        float f=1.5f;
        double d;
        d=(double)f;

        ~RaGE();

        R Offline
        R Offline
        RaajaOfSelf
        wrote on last edited by
        #3

        if u are using c++ double_var=static_cast(float_var)

        1 Reply Last reply
        0
        • W wow9999

          Dear all How to convert float to double? Thanks

          R Offline
          R Offline
          Reservoir Dog
          wrote on last edited by
          #4

          you can do the following float f = some_value; . . . double d = static_cast(f); think it should work! And you will know my name is the Lord when I lay my vengeance upon thee.

          1 Reply Last reply
          0
          • R Rage

            Is this not working ?

            float f=1.5f;
            double d;
            d=(double)f;

            ~RaGE();

            J Offline
            J Offline
            Jambolo
            wrote on last edited by
            #5

            d=(double)f; d=static_cast(f); Interesting. This always works for me: d = f; ;)

            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