[PLUG] C compiler question

stuart mathews smathews at pcez.com
Tue Feb 4 06:29:01 UTC 2003


>
>This might prove to be a fascinating conversation. There is not really
>enough information to make even an educated guess on the subject so lets
>start with the revisions of the compilers (gcc / linux 2.xx??) and the
>processor architecture (is this 64 bit precision math on an ix86 vs. 64
>bit precision on a SPARC or Alpha etc...)?  Some detail please.
>

Here is more info on the situation.

Compiler; gcc version 3.2 20020903
Kernel;   2.4.18-14 (Redhat 8.0)
Hardware; P4 (Thinkpad, NOT the Compaq box)
Preprocessor architecture; I don't know for sure if what I am attempting to
do is 64-bit precision math or not - remember, I'm the perpetual newbie here.


Code;
#include <stdio.h>
int main(void)
{
   float a, b;
   
   b = 2.0e20 + 1.0;
   a = b - 2.0e20;
   printf("%f \n", a);
   return 0;
}

The output is supposed to reflect the fact that the computer doesn't keep track
of enough decimal places to do the operation correctly. That's all well and
good, but then the book goes on to say that the output will be one of the following,
and my output matches exactly that of the "CodeWarrior;

gcc, Linux;   0.000000
Turbo C 1.5;  -13584010575872.000000
CodeWarrior;  4008175468544.000000

Incidentally, when I try to open vi to view the source file I get the following
message;

E325: ATTENTION
Found a swap file by the name ".floaterr.c.swap" while opening file "floaterr.c"


1. Another program may be editing the same file.....
2. An edit session for this file crashed. If this is the case, use ":recover"
or............"


-------------------
http://www.pcez.com




More information about the PLUG mailing list