Floating Point Error?

From: Kosmas Papachristos <papahr_at_ics.forth.gr>
Date: Tue, 01 Aug 1995 18:05:59 +0300

Hello managers,

 Has anyone else noticed the following strange behavior?

Run the following program:

#include <stdio.h>

void main()
{
float fnum,dec;

        fnum = 0.18;
        printf("FNUM = %f\n",fnum);
        dec = fnum * 10000.0;
        printf("DEC = %f\n",dec);
}

and you will get :
FNUM = 0.180000
DEC = 1800.000122

This same output is produced using both cc and gcc-2.7.0
The machine I run this code is a DEC 3000/600 with OSF1/v3.2

If instead of float, use double the problem disappears !
..I didn't notice any sign ``Pentium inside'' on the cover though..


        Kosmas Papachristos
Received on Tue Aug 01 1995 - 17:22:28 NZST

This archive was generated by hypermail 2.4.0 : Wed Nov 08 2023 - 11:53:45 NZDT