Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!usc!ucla-cs!ucla-ma!news From: barry@pico.math.ucla.edu (Barry Merriman) Newsgroups: comp.sys.next Subject: Re: Bug in 68040 chip Message-ID: <1991Mar5.030910.9204@math.ucla.edu> Date: 5 Mar 91 03:09:10 GMT Sender: news@math.ucla.edu Organization: UCLA Dept. of Math, UCLA Inst. for Fusion and Plasma Research Lines: 82 Here's an update on the bug in the tanh(x) function. (I have reported it to Next, by the way, but they have not had time to get back to me yet). After further experimenting by folks on the mathematica mailing list, and input from folks who understand the 68040 transcendental evaluation, I'd say my best guess is this: The assembly program that evaluates the FTANH function for the 68040 is buggy. As others have explained, when the FTANH function is called on the 68040 (or 030 in the absence of a coprocessor), some chunk of assembly code gets executed to produce the result. It seems that under 2.0, this code (which might(?) be part of the 2.0 kernel) is buggy. If your code includes math.h, it may be able to avoid this bug by using the C library tanh(x), which apparently does not actually call the 680*0 FTANH function---at least for the 030. To diagnose your machine, here are two minimal testcodes donated by *Cameron Smith*: ----------------------------------------------------------- The following is a transcript of a brief test I ran on my NeXT. I have NeXT's 2.0 operating system, and an '030 processor. (Heorot is the machine's name.) Heorot (104) > cat testmath1.c #include main() { printf("%g %g\n", tanh(-1.73287), tanh(-1.73288)); } Heorot (105) > make testmath1.c cc testmath1.c -o testmath1 Heorot (106) > testmath1 -0.939394 -0.939395 Heorot (107) > cat testmath2.c main() { printf("%g %g\n", tanh(-1.73287), tanh(-1.73288)); } Heorot (108) > make testmath2 cc testmath2.c -o testmath2 Heorot (109) > testmath2 -0.939394 -1.73288 Did you see it? If I compile the program WITH the #include line, then tanh works just fine! But if I compile without the #include line (a "minimal" program?) the promised discontinuity appears! --Cameron Smith ------------------------------------------------------------- AS I said, I'm guessing that when math.h is not present, the call to tanh is trapped in the 68030/040 and sent off chip to some kernel code for evaluation in OS 2.0. This kernel code is what must be in error, and from the graph in Mathematica, we can see the error is a - that should be a +. -- Barry Merriman UCLA Dept. of Math UCLA Inst. for Fusion and Plasma Research barry@math.ucla.edu (Internet)