[comp.lang.perl] problems with pack/unpack

billl@oakhill.UUCP (Bill Ledbetter) (03/22/90)

(I tried to mail this yesterday, but it looks like it got lost.)

After receiving some news that the pack/unpack script I posted worked on
other machines, I began to look a little further.  I found that the sun3
compilers did not seem to handle the (unsigned int) cast required by the
pack operator properly.  The following code fragment shows the problem:

main()
{
	double f0;
	unsigned int u0, u1;
	int i0, i1;

	u0 = 0x89abcdef;
	printf("U0:%08x\n", u0);

	i0 = (int)u0;
	f0 = (double)i0;
	printf("F0: %f  I0:%08x\n", f0, i0);
	u1 = (unsigned int)f0;
	i1 = (int)f0;
	printf("U1:%08x  I1:%08x\n", u1, i1);
}

When this is compiled without the 68881, the u1 variable gets 0 from the
coercion.  With the 68881, u1 gets the proper value.

For now, I will always compile with the -f68881 flag!

---------------------------------------------------------------------------
Bill Ledbetter
Motorola Inc.    MD OE37                 email: cs.utexas.edu!oakhill!billl
6501 William Cannon Dr. West
Austin, TX 78735-8598