Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!usc!brutus.cs.uiuc.edu!unix.cis.pitt.edu!ding From: ding@unix.cis.pitt.edu (Yijun Ding) Newsgroups: comp.lang.c Subject: TC floating point Message-ID: <22449@unix.cis.pitt.edu> Date: 21 Feb 90 16:04:38 GMT Distribution: usa Organization: Univ. of Pittsburgh, Computing & Information Services Lines: 34 After reading TC sizeof() in the news group, here is a program to show bugs in TC 2.0: #include char buf[80]; double x, *f; main() { test1(); test2(); } test2() { /* error: floating point format not linked */ /* solution: x=sin(1) */ f = (double *)malloc(sizeof(double)*10); scanf("%lf",f); printf("%lf\n",*f); } test1() { /* number of digits after decimal incorrect */ x = 3.14; sprintf(buf,"%8.0e %8.1e %8.2e %8.3e\n",x,x,x,x); puts(buf); } The bug in test1() in not important, but I am still looking best way to avoid the problem in test2(). TC will load floating point routine 'automatically' for you. It is fooled when malloc() is used, even the program involves lengthy numerical calculations.