Mircosoft C V5.1 floating point problem.

Kevin D. Quitt kdq at demott.COM
Fri Aug 10 03:27:30 AEST 1990


In article <5587 at castle.ed.ac.uk> elee24 at 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 at 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.



More information about the Comp.lang.c mailing list