Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6751653
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:57:09+00:00 2026-05-26T12:57:09+00:00

I am cleaning up some of our network-code and while replacing various integer types

  • 0

I am cleaning up some of our network-code and while replacing various integer types (int, unsigned short, …) with more explcit typedefs such as int32_t and uint16_t I was wondering how portable double and float are between different compilers. We are sending structures similar to the following:

struct foo
{
   uint32_t id;
   double dbl;
};

...

// copy_packed() copies packed bytes of integral type and adheres 
// to network byte-ordering
copy_packed(int32_t data, char* buffer, char* end);
copy_packed(uint32_t data, char* buffer, char* end);
copy_packed(uint16_t data, char* buffer, char* end);

...
// overload for structure types calls overloads for its members
void copy_packed(foo &data, char* buffer, char* end)
{
    copy_packed(data.id, buffer); 
    copy_packed(data.id, buffer); 
};

Until now only programs compiled with VC++ are used, but use of the protocol on GCC is scheduled.

The question is now: can double amd float be safely send over the wire even when then interpreted by different compilers? The question – as far as I understand – boils down to whether GCC and VC++ comply to IEEE754. Or maybe provide functions to convert to conformant packaging?

Any hints on the matter?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T12:57:09+00:00Added an answer on May 26, 2026 at 12:57 pm

    Not very. IEEE doesn’t define byte order, and not all systems are IEEE.
    The real question is how portable you have to be. IEEE is pretty much
    universal for modern Unix platforms, as well as Windows; if your
    portability is limited to these, you can generally type pun a float
    into a uint32_t, and a double into a uint64_t, and handle input and
    output that way. If you have to take mainframes into consideration (and
    possibly embedded processors—I’m less familiar about those),
    you’ll have a lot more work to do; floating point on the major
    mainframes isn’t even base 2.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

While cleaning some code today written by someone else, I changed the access modifier
I've just installed the 3.5 .NET Framework and while doing some cleaning I've notice
I'm cleaning up some localisation and translation settings in our PyGTK application. The app
I am cleaning up some code in a C# app that I wrote and
I am cleaning up some old code converting it to work asynchronously. psDelegate.GetStops decStops
I'm cleaning up some pretty complicated code that I didn't write and I'm looking
I'm working on cleaning up some of my code and I came to a
Today, I was cleaning up some of my code with FXCop and it complained
As I was cleaning up some code, FindBugs pointed me to a bit of
I'm cleaning up some legacy framework code and a huge amount of it is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.