Date: Mon, 19 Mar 2001 09:37:48 +0200 (IST) From: Eli Zaretskii X-Sender: eliz AT is To: Jason Green cc: djgpp AT delorie DOT com Subject: Re: Whats up with sqrt? In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On Sun, 18 Mar 2001, Jason Green wrote: > "Eli Zaretskii" wrote: > > > In fact, for most arguments, code produced by latest versions of GCC > > doesn't even call the library function, it emits an FP instruction > > that computes the square root directly. > > What arguments would cause the library function to be called? Only those which cause the FSQRT instruction to produce Inf or NaN. You can clearly see this in the code produced by GCC, if you compile a simple C source with "gcc -S" and examine the assembly: it issues FSQRT, and then examines the C0..C3 condition code bits in the x87 status word. If these bits say that the result is abnormal, the library function is called to cope with the problem. (This is one more reason why it is a good idea to mask numeric exception in the startup code, as latest versions of DJGPP do: if you don't do that, you will have SIGFPEs even if the library is written to carefully avoid them.)