delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/09/03/12:31:58

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
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 <cygwin-erikd AT mega-nerd DOT com>
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
X-IsSubscribed: yes

Brian Dessent wrote:

> Yes, this does in fact seem to be a bug in lrintf.  A reduced testcase
> is:
> 
> #include <stdio.h>
> #include <math.h>
> 
> 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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019