paquette@cpsc.ucalgary.ca (Trevor Paquette) (02/28/89)
As some of you I have been having problems with the xdr routines on the 3000 series Iris. Well I have come across what I think is a possible bug. (BTW, thaks to all of you who have helped me so far). Below is two programs that I am using to test the xdr_double routines. Program 1 is run on the Iris to generate the file, program 2 is used on a sun to read in the file. /*** Program 1 ***/ #include <rpc/rpc.h> #include <stdio.h> main() { double d; int i; XDR xdrs; FILE *out; out = fopen("test","w"); xdrstdio_create(&xdrs, out, XDR_ENCODE); for(i = 0; i < 10; i++) { d = (double)i; xdr_double(&xdrs, &d); } fclose(out); } /*** Program 2 ***/ #include <rpc/rpc.h> #include <stdio.h> main() { double j; XDR xdrs; FILE *in; in = fopen("test","r"); xdrstdio_create(&xdrs, in, XDR_DECODE); while(xdr_double(&xdrs, &j)) fprintf(stdout,"%lf ",j); fprintf(stdout,"\n"); fclose(in); } This is the file test that is output by program 1 when run on the iris. (compiled with cc prog1.c -lsun -lbsd) Off- Set ------------- Hex Dump Values ----------------- ---- Ascii ----- 0 00 00 00 00 00 00 00 00 3e 00 08 7c 00 00 00 00 ........>..|.... 10 40 00 06 fc 00 00 00 00 40 00 07 3c 00 00 00 00 @.......@..<.... 20 40 00 07 7c 00 00 00 00 40 00 07 9c 00 00 00 00 @..|....@....... 30 40 00 07 bc 00 00 00 00 40 00 07 dc 00 00 00 00 @.......@....... 40 40 00 07 fc 00 00 00 00 40 00 08 0c 00 00 00 00 @.......@....... This is the output that program 2 generates.. 0.000000 0.000000 2.003410 2.003532 2.003654 2.003716 2.003777 2.003838 2.003899 2.003929 Do even close to what I'd expect.. This is the file test that is generated by the sun when program 1 is run on it. Off- Set ------------- Hex Dump Values ----------------- ---- Ascii ----- 0 00 00 00 00 00 00 00 00 3f f0 00 00 00 00 00 00 ........?....... 10 40 00 00 00 00 00 00 00 40 08 00 00 00 00 00 00 @.......@....... 20 40 10 00 00 00 00 00 00 40 14 00 00 00 00 00 00 @.......@....... 30 40 18 00 00 00 00 00 00 40 1c 00 00 00 00 00 00 @.......@....... 40 40 20 00 00 00 00 00 00 40 22 00 00 00 00 00 00 @ ......@"...... This is the output that program 2 generates when run on the Iris. 0.000000 0.000040 163840.000001 163968.000001 164096.000001 164160.000001 164224.000001 164288.000001 164352.000001 164384.000001 Again this is not even close to what is suppose to be generated. When program 1 and program 2 are run both on the sun the output is as expected.. 0.000000 1.000000 2.000000 3.000000 4.000000 5.000000 6.000000 7.000000 8.000000 9.000000 When program 1 and program 2 are both run on the Iris again the output is all wrong.. (which seems to be really bad..) 0.000000 0.007813 2.000000 32.000000 512.000000 2048.000000 8192.000000 32768.000000 131072.000001 262144.000002 Could the problem be that sizeof(float) and sizeof(double) are the same on the Iris 3000 series??? If so then why weren't the xdr routines in libsun.a changed to reflect this? Is there a fix for this? Or am I missing something totally obvious? Trev ============================================================================== Trevor Paquette/GraphicsLand, Calgary, Alberta ..uunet!{ubc-cs,utai,alberta}!calgary!paquette ICBM:51 03 N/114 05 W calgary!paquette@cs.ubc.ca Luminous beings we are, not this crude matter