delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/06/28/15:49:37

From: invalid AT erehwon DOT invalid (Graaagh the Mighty)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: DJGPP reserves wrong int size
Organization: Low Charisma Anonymous
Message-ID: <3b3b4e40.213415946@news.primus.ca>
References: <9dde68b7 DOT 0106241053 DOT 2a385311 AT posting DOT google DOT com> <200106242138 DOT RAA18013 AT envy DOT delorie DOT com> <3b37e92e DOT 288745911 AT news DOT primus DOT ca> <200106260242 DOT WAA00615 AT envy DOT delorie DOT com>
X-Newsreader: Forte Free Agent 1.11/32.235
Lines: 41
Date: Thu, 28 Jun 2001 15:41:40 GMT
NNTP-Posting-Host: 207.176.153.146
X-Complaints-To: news AT primus DOT ca
X-Trace: news1.tor.primus.ca 993742968 207.176.153.146 (Thu, 28 Jun 2001 11:42:48 EDT)
NNTP-Posting-Date: Thu, 28 Jun 2001 11:42:48 EDT
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

On Mon, 25 Jun 2001 22:42:11 -0400, DJ Delorie <dj AT delorie DOT com> sat on
a tribble, which squeaked:

>And long doubles should be 16-byte aligned (128 bits)...

I mentioned regular doubles in the earlier posting, rather than long
doubles. Long doubles seem to be broken in gcc 2.95.2 anyway -- at
least, when I wrote the stuff I am working on it initially used long
doubles, and gave bogus results; adding debugging printfs I discovered
that some values were strangely becoming zeroes that shouldn't have
been. It worked when I changed every occurrence of "long double" to
"ldouble", then typedef'd that as "double". Change the typedef to
"long double" and the zeros reappear. I thought at first that maybe I
needed a special formatting symbol to use them properly in printf, but
a libc info a printf soon set me straight -- a short way down the page
it said "'f' -- a floating point number (double or long double)"
indicating that "%f" should work either way. (Actually, I tend to use
"%1.16f" when debugging FP code, since the default "%f" gives only
"float" precision output even when doubles and long doubles are
passed. Clearly this should work fine with long doubles, except that
even 16 digits of precision might not be enough for many cases.)
Besides, there was the bogus output from the program with long doubles
even without the printfs. The numbers weren't just being read out
bogusly, they were already bogus to begin with... As for where they
came from, they came from passing literals to functions or using them
in assignments -- I hadn't yet written any input code, for testing I
just changed constants and recompiled. In particular, they weren't
coming from scanf, which I know does care more about the size of its
targets, since it will necessarily blow up if you pass it addresses of
spaces of the wrong size... I am somewhat curious as to how printf
knows the format of a double or for that matter int you pass it
however. It might be different bit lengths, and it's a varargs
function, but the above suggests that once it's told it's looking for
a float as opposed to, say, an int, it can tell a double from a long
double...

-- 
Bill Gates: "No computer will ever need more than 640K of RAM." -- 1980
"There's nobody getting rich writing software that I know of." -- 1980
"This antitrust thing will blow over." -- 1998
Combine neo, an underscore, and one thousand sixty-one to make my hotmail addy.

- Raw text -


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