From: "H.W. Stockman" Newsgroups: comp.os.msdos.djgpp Subject: Re: Floating point => int Date: Fri, 10 Oct 1997 17:46:43 -0600 Organization: Lentil Sorbet, Inc. Lines: 20 Message-ID: <343EBE63.447A@swcp.com> References: <343E7D7B DOT 9CE55810 AT worldonline DOT nl> <19971010225701 DOT SAA11869 AT ladder01 DOT news DOT aol DOT com> Reply-To: hwstock AT swcp DOT com NNTP-Posting-Host: ppp51.swcp.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Reinier Heeres wrote: > Hi! >A floating point exception seems to occur sometimes when I convert a >float to an int. >I use _control87() to make sure all the floating point exceptions, >except for the invalid operation exception, are handled internally. If I >put the flag for the invalid operation exception on, my program seems to >hang... If the float has a magnitude that is too large to represent as an int, the exception may occur. One brute force procedure is to do bounds checking on the float before the conversion (perhaps this can be worked into the bounds of a for(), with a bit of forethought, no pun intended). Unless you want to mask the exception, or write an fp exception handler, there aren't too many choices...