Menu

Storing safely floating p. num. in binary fmt

2002-08-20
2012-09-26
  • Nobody/Anonymous

    Does the C floating point number is architecture (big/little endian) independent?

    Or I have to do sth. like this:

    double theNumber = number2write;
    int32 *conv;
    conv = &theNumber;
    *conv = swap_2_BE_if_needed(*conv);
    conv++;
    *conv = swap_2_BE_if_needed(*conv);
    conv--;
    fwrite(conv, 4, 2, myFile);

    and reverse when I read the number?

      Pawel

     
    • Nobody/Anonymous

      C is architecture DEPENDENT.

      If you need architecture independence, you can try programming in Java instead...

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.