From: myskin AT inp DOT nsk DOT su (Vyacheslav O. Myskin) Newsgroups: comp.os.msdos.djgpp Subject: double-->int: What's wrong here? Date: Wed, 05 Feb 1997 13:37:25 GMT Organization: BINP RAS Lines: 31 Distribution: world Message-ID: <32f887b7.44544@news-win.inp.nsk.su> Reply-To: myskin AT inp DOT nsk DOT su NNTP-Posting-Host: csd-bsdi.inp.nsk.su To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Hi everybody! Please explain me what is wrong with this: ------------------------------------------------------------------ #include int main() { double d1,d2; int n1,n2; d1=1./4300.; n1=(int)(.05/d1); d2=.05/d1; n2=(int)d2; printf("n1=%d n2=%d d2=%f\n",n1,n2,d2); return 0; } ------------------------------------------------------------------- Compiled with DJGPP 2.01, options: -O0 -g -Wall The output is: n1=214 n2=215 d2=215.000000 So why n1 is not equal to n2? It's not fun because I used n1 as an argument to malloc() and kept getting SIGSEGVs later :( My machine is 486DX. Vyacheslav