Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!srhqla!demott!kdq From: kdq@demott.COM (Kevin D. Quitt) Newsgroups: comp.lang.c Subject: Re: Mircosoft C V5.1 floating point problem. Message-ID: <470@demott.COM> Date: 9 Aug 90 17:27:30 GMT References: <5587@castle.ed.ac.uk> Reply-To: kdq@demott.COM (Kevin D. Quitt) Organization: DeMott Electronics Co., Van Nuys CA Lines: 45 In article <5587@castle.ed.ac.uk> elee24@castle.ed.ac.uk (H Bruce) writes: >I am working on a large program that has suddenly starting crashing with >the following error: > >floating pointing exection >M6101 invalid > >The manual says it is caused by operating on a NAN (not a number !) which is >not much help. I ran into the same problem, when I was getting binary data from another system - it was providing me with infinities. One way to handle it is to use signal( SIGFPE, your_function_here ) to catch the problem (don't forget to reset the signal inside your function). The approach I'm taking, since all my data comes in from the outside world, is to filter the data looking for NANs and Infinities. I check the value of the high order word (specifcally, the exponent of the fp value). 1) Mask off the high bit (sign of fraction) 2) Check to see if the value of the words exceeds the max given below If so, it's an infinity or a NAN. 3) If it's less than the min value below, and the rest of the FP value is non-zero, it's a denormalized number, and you probably don't wan't to much with it either. Max Min type value value float 7F80 0080 doble 7FF0 0010 extend 7FFF 0001 In any case, check out the 287 manual, or that for the 68881 - they've got the encodings there. Good luck! -- _ Kevin D. Quitt demott!kdq kdq@demott.com DeMott Electronics Co. 14707 Keswick St. Van Nuys, CA 91405-1266 VOICE (818) 988-4975 FAX (818) 997-1190 MODEM (818) 997-4496 PEP last 96.37% of all statistics are made up.