www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/06/27/15:03:03

From: Erik Berglund <erik2 DOT berglund AT telia DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Possible truncation error
Lines: 29
Message-ID: <_x665.15310$Za1.242989@newsc.telia.net>
Date: Tue, 27 Jun 2000 18:39:54 GMT
NNTP-Posting-Host: 194.237.157.182
X-Complaints-To: abuse AT telia DOT com
X-Trace: newsc.telia.net 962131194 194.237.157.182 (Tue, 27 Jun 2000 20:39:54 MET DST)
NNTP-Posting-Date: Tue, 27 Jun 2000 20:39:54 MET DST
Organization: Telia Internet
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Hi, I tried the following program, which gives
j=9999. I think the right result should be 10000,
because a=0x40c3880000000000, which is exactly 10000.

#include <stdio.h>
#include <math.h>
int main() {
double a;
int j,*p;

   a = pow(100,2);
   j = a;
   p = (int*)&a;
   printf("%08x%08x\n",*(p+1),*p);
   printf("%i\n",j);
   return(0);
}

If I insert a printf("\n") before j=a;, the result
becomes 10000 instead, and I have no idea why.

Thanks in advance,

--

Erik Berglund
erik2 DOT berglund AT telia DOT com


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019