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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How do I convert a double to binary

How do I convert a double to binary

Scheduled Pinned Locked Moved C / C++ / MFC
windows-admintutorialquestion
3 Posts 2 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.
  • P Offline
    P Offline
    panks_r
    wrote on last edited by
    #1

    I have to store a DateTime in the registry in binary key. I think i can use the DateTime.m_dt variable which a double to store the value of the datetime. But I don't know how to convert it to binary like in Managed where we have the BitConverter.GetBytes(double). I need this urgently.

    stefanmihaimogaS 1 Reply Last reply
    0
    • P panks_r

      I have to store a DateTime in the registry in binary key. I think i can use the DateTime.m_dt variable which a double to store the value of the datetime. But I don't know how to convert it to binary like in Managed where we have the BitConverter.GetBytes(double). I need this urgently.

      stefanmihaimogaS Offline
      stefanmihaimogaS Offline
      stefanmihaimoga
      wrote on last edited by
      #2

      Hi, you can use a union with a buffer of 8 bytes and your DateTime.m_dt variable, like in the following example: typedef union DateTimeConversionTag { char m_buffer[8]; double m_datetime; } DateTimeConversion; http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclang/html/_pluslang_typedef_specifier.asp[^] http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclang/html/_pluslang_unions.asp[^]

      P 1 Reply Last reply
      0
      • stefanmihaimogaS stefanmihaimoga

        Hi, you can use a union with a buffer of 8 bytes and your DateTime.m_dt variable, like in the following example: typedef union DateTimeConversionTag { char m_buffer[8]; double m_datetime; } DateTimeConversion; http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclang/html/_pluslang_typedef_specifier.asp[^] http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclang/html/_pluslang_unions.asp[^]

        P Offline
        P Offline
        panks_r
        wrote on last edited by
        #3

        Thanks a ton Mihai!!!u posted just in time

        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