Subject: Re: Encoding of doulbes by xdr
To: J.T. Conklin <jconklin@netcom.com>
From: Kent Vander Velden <graphix@iastate.edu>
List: current-users
Date: 03/21/1995 22:12:03
In message <199503212014.MAA25895@netcom20.netcom.com>, jconklin@netcom.com wri
tes:
>> Has anyone else noticed the xdr library does not seem to encode doubles
>> properly? At least this seems to be the case with version 12.1 of libc.
>
>Do you have some example code that fails? On what architecture are you
>encountering failures.
i386 architecture
example code:
#include <stdio.h>
#include <stdlib.h>
#include <rpc/types.h>
#include <rpc/xdr.h>
int
main(void) {
double x=3.14159;
double y=0.0;
char *xdr_buffer=NULL;
XDR xdrs;
int nbytes=sizeof(double);
xdr_buffer = (char*)malloc(nbytes);
xdrmem_create(&xdrs, xdr_buffer, nbytes, XDR_ENCODE);
xdr_double(&xdrs, &x);
xdr_destroy(&xdrs);
xdrmem_create(&xdrs, xdr_buffer, nbytes, XDR_DECODE);
xdr_double(&xdrs, &y);
xdr_destroy(&xdrs);
free(xdr_buffer);
printf("before encoding=%f\nafter encoding=%f\n", x, y);
return 0;
}
example results:
before encoding=3.141590
after encoding=-10683321609893104454175034763405708008063329617849858696815696097337486842230719357143679172008298562466964440577435979420962398737579232393354786421772637683370419217363074653701888571608996294938219310663181602857278529041210540032.000000
>I tested this extensively when I first made it work, but it is
>possible that someone's broken it since then.
>
>I'll take a look.
>
> --jtc
I noticed and a friend pointed out that xdr_float.c was updated in the last
couple of days. The last time that I built and installed current was on March
19.
---
Kent Vander Velden
graphix@iastate.edu