Richard,

As of interest, I've modified your code below and ran on two systems:
a) Sun Ultra-Enterprise SPARC (gcc)
b) Windows XP AMD (VS .NET 2003)

Code snippet:

union utest {
  double r;
  long long i;
  unsigned char z[8];
};

float  test_2;

int main(int argc, char **argv){
  union utest x;
  x.r = 1.0;
  printf("%02x%02x%02x%02x%02x%02x%02x%02x\n",
    x.z[0], x.z[1], x.z[2], x.z[3], x.z[4], x.z[5], x.z[6], x.z[7]);
  x.i = 1;
  printf("%02x%02x%02x%02x%02x%02x%02x%02x\n",
    x.z[0], x.z[1], x.z[2], x.z[3], x.z[4], x.z[5], x.z[6], x.z[7]);

  test_2 = 1.0;

  printf("%08x\n", *((unsigned int *) &test_2) );

  return 0;
}

Results:

a)

3ff0000000000000
0000000000000001
3f800000
wsi012 (16) file test2
test2:          ELF 32-bit MSB executable SPARC Version 1, dynamically
linked, not stripped

b)

000000000000f03f
0100000000000000
3f800000

Regards
Nick

********************************************************************
This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender.
You should not copy it or use it for any purpose nor disclose or
distribute its contents to any other person.
********************************************************************

Reply via email to