Re: bcc vs cc/gcc (float)

[ Available lists | Index of freebsd-hackers | Month of May 1997 | Week of 31 May 1997 | Raw email | View thread | Wrap long lines | Reply ]
From
J Wunsch <j@uriah.heep.sax.de>
Date
31 May 1997 00:50:54
Subject
Re: bcc vs cc/gcc (float)
Message-ID
19970531092837.DA51579@uriah.heep.sax.de

References to
Replies
Referenced by

[ Hide this part ]
As Steve Howe wrote:

> i have taken a great deal of time creating this code to
> show this point - and it should compile cleanly as is
> under bcc/cc/gcc. Borland C (4.51) can run this code
> without any loss of accuracy. please CC me, i'm not
> subscribed.

Well, you should perhaps have posted the expected output... instead of
relying on people having a Borland C. (Btw., ``bcc'' here usually
refers to ``Bruce's C compiler'' which can be found in the FreeBSD
ports collection, and is expected to be older than Borland's use of
the term `bcc'. ;-)

I'm not much surprised that the use of non-standard components (long
double) produces unexpected results. You multiply a long double with
a double (result of pow()), so who tells you whether the compiler does
it by first extending the result of pow() to long double format (thus
`inventing' missing precision digits), or by first truncating the long
double (although i wouldn't expect this)?

> void main (unsigned char argc, unsigned char **argv) {

Don't get caught in comp.lang.c with this. :) It's an invalid
definition of main, thus the behaviour is implementation-dependant.
gcc could have exited immediately without violating the standard.

The only valid declarations of main() are:

int main(int, char **)
int main(void)

Also, your blatant use of unsigned char for everything doesn't look
right. At least with gcc, using an unsigned char as a loop index
counter isn't doing any good and is likely to slow down your code. It
doesn't save space at all, since (i think) %dh, %dl, and %edx are all
a single register for gcc, regardless of how many bits you're using.

--
cheers, J"org

joerg_wunsch@uriah.heep.sax.de -- http://www.sax.de/~joerg/ -- NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)


Elapsed time: 0.116 seconds