title: Unable to return same double using Google Protocol Buffers from C# to C++ and back
body: <p>I'm trying to communicate between C# and C++ with varying amounts of success.</p>
  
  <p>I am able to send a message between the two using reply/request, but the doubles that I am receiving are not correct. </p>
  
  <p>For debugging purposes and understanding, I am currently running the following:</p>
  
  <p>Clrzmq 3.0 rc1, Google ProtocolBuffer 2.5, Protobuf-csharp-port-2.4, ZeroMQ-3.2.3</p>
  
  <p>.Proto</p>
  
  <pre><code>package InternalComm;
  
  message Point 
  {
      optional double x = 1;
      optional double y = 2;
      optional string label = 3;
  }
  </code></pre>
  
  <p>server.cpp (the relevant part)</p>
  
  <pre><code>while (true) {
      zmq::message_t request;
  
      // Wait for next request from client
      socket.recv (&amp;request);
      zmq::message_t reply (request.size());
      memcpy ((void*)reply.data(), request.data(), request.size());
      socket.send(reply);
  }
  </code></pre>
  
  <p>client.cs (the relevant part)</p>
  
  <pre><code>public static Point ProtobufPoint(Point point)
      {
          Point rtn = new Point(0,0);
          using (var context = ZmqContext.Create())
          {
              using (ZmqSocket requester = context.CreateSocket(SocketType.REQ))
              {
                  requester.Connect("tcp://localhost:5555");
                  var p = InternalComm.Point.CreateBuilder().SetX(point.X).SetY(point.Y).Build().ToByteArray();
  
                  requester.Send(p);
  
                  string reply = requester.Receive(Encoding.ASCII);
                  Console.WriteLine("Input: {0}", point);
  
                  byte[] bytes = System.Text.Encoding.ASCII.GetBytes(reply);
                  var message = InternalComm.Point.ParseFrom(bytes);
                  rtn.X = message.X;
                  rtn.Y = message.Y;
  
                  Console.WriteLine("Output: {0}", rtn);
              }
          }
          return rtn;
      }
  </code></pre>
  
  <p>On the C# side, Point is a very simple struct. Just x and y properties.</p>
  
  <p>Here is what I'm getting from my unit tests as a result of running the above code.</p>
  
  <blockquote>
    <p>Input (1.31616874365468, 4.55516872325469)
    <br />
    Output (0.000473917985115791, 4.55516872323627)
    <br /></p>
    
    <p>Input (274.120398471829, 274.128936418736) 
    <br />
    Output (274.077917334613, 274.128936049925)</p>
    
    <p>Input (150.123798461987, 2.345E-12) 
    <br />
    Output (145.976459594794, 1.11014954927532E-13)</p>
    
    <p>Input (150, 0) 
    <br />
    Output (145.96875, 0)</p>
  </blockquote>
  
  <p>I am thinking that the problem is my protobuf code is incorrect (doubtful this is a bug on Skeet's side). I am also running under the assumption that server.cpp is doing nothing to the message but returning it as is.</p>
  
  <p>Thoughts?</p>