From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,22bd6c59c2b711b4,start X-Google-Attributes: gidfee84,public From: interval@my-deja.com Subject: problem with the function ecvt Date: 1999/12/01 Message-ID: <823maf$lbi$1@nnrp1.deja.com>#1/1 X-Deja-AN: 555258499 X-Http-Proxy: 1.1 x27.deja.com:80 (Squid/1.1.22) for client 193.48.190.219 Organization: Deja.com - Before you buy. X-Article-Creation-Date: Wed Dec 01 17:36:15 1999 GMT X-MyDeja-Info: XMYDJUIDinterval Newsgroups: comp.unix.osf.osf1 X-Http-User-Agent: Mozilla/4.0 (compatible; MSIE 4.5; Mac_PowerPC) The documentation describes that the function ecvt rounds the number according to the rounding mode. I try to use it but I get wrong values. My program is : /*---------------*/ #include #include #include #include void print(double t); void print(double t) { int dec,sign; char *buffer; printf("%E :",t); buffer=ecvt(t,10,&dec,&sign); printf("%c%s (%d)\n",(sign==0)?'+':'-',buffer,dec); } int main(void) { double pi; write_rnd(FP_RND_RN); printf("round mode:%u\n",read_rnd()); pi=atan2(0.E0,-1.E0); print(pi); print(-pi); write_rnd(FP_RND_RP); printf("round mode:%u\n",read_rnd()); print(pi); print(-pi); write_rnd(FP_RND_RM); printf("round mode:%u\n",read_rnd()); print(pi); print(-pi); return 0; } /*--------*/ I compile it with : cc -fprm d -ieee ecv.c -lm I get these results : round mode:1 3.141593E+00 :+3141592654 (1) -3.141593E+00 :-3141592654 (1) round mode:2 3.141593E+00 :+3141592654 (1) -3.141593E+00 :-3141592654 (1) round mode:3 3.141593E+00 :+3141592654 (1) -3.141593E+00 :-3141592654 (1) What is wrong in my program ? Thanks Sent via Deja.com http://www.deja.com/ Before you buy.