Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Date: Sun, 4 Sep 2005 02:31:43 +1000 From: Erik de Castro Lopo To: cygwin AT cygwin DOT com Subject: Re: [patch] lrint/lrintf oddity Message-Id: <20050904023143.48fed0c5.cygwin-erikd@mega-nerd.com> In-Reply-To: <4319C016.2958BC77@dessent.net> References: <20050903185145 DOT 5bb6c57e DOT cygwin-erikd AT mega-nerd DOT com> <4319C016 DOT 2958BC77 AT dessent DOT net> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Brian Dessent wrote: > Yes, this does in fact seem to be a bug in lrintf. A reduced testcase > is: > > #include > #include > > int main () > { > float f = -8399916.0; > printf ("f = %f, k = %ld\n", f, lrintf (f)); > } > > The value -8399916.0 in binary is > > 1 10010110 00000000010110000101100 > > The exponent (j0) is 23 (150 - 127 = 23). > > In lrintf, the problem is the part of the algorithm that acts on the > case of 23 <= j0 < 31. In this case, the mantissa is simply extracted > and shifted left by (j0 - 23). This is handled by line 66 of > sf_lrint.c: Err, what?????????????? On Linux, the lrintf() function is an inline function that reduces to a single asm instruction. I'm using lrintf() to convert huge arrays of floats to ints. I'd like that to be reasonably quick :-). Any chance of replacing all that code you've got with a single inline asm instruction like Linux has? Erik -- +-----------------------------------------------------------+ Erik de Castro Lopo nospam AT mega-nerd DOT com (Yes it's valid) +-----------------------------------------------------------+ "Who would have believed that reading and writing would pay off?" -- Homer Simpson -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/