delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2003/09/29/14:13:58

X-Authentication-Warning: delorie.com: mail set sender to djgpp-workers-bounces using -f
Date: Mon, 29 Sep 2003 13:14:18 +0300 (EET DST)
From: Esa A E Peuha <peuha AT cc DOT helsinki DOT fi>
Sender: peuha AT sirppi DOT helsinki DOT fi
To: djgpp-workers AT delorie DOT com
Subject: Re: Bug in modfl() in libc.a
In-Reply-To: <3F7570EB.6DB49520@phekda.freeserve.co.uk>
Message-ID: <Pine.OSF.4.58.0309291309410.26476@sirppi.helsinki.fi>
References: <163 DOT 2566e055 DOT 2c8f7691 AT aol DOT com> <Pine DOT OSF DOT 4 DOT 58 DOT 0309181250050 DOT 11935 AT sirppi DOT helsinki DOT fi>
<3F7570EB DOT 6DB49520 AT phekda DOT freeserve DOT co DOT uk>
MIME-Version: 1.0
Reply-To: djgpp-workers AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Sat, 27 Sep 2003, Richard Dawe wrote:

> modf(+-x, iptr) returns a result with the same sign as x.
> modf(+-Inf , iptr) returns +-0 and stores +-Inf in the object pointed to by
> iptr.
> modf(NaN, iptr) stores a NaN in the object pointed to by iptr (and returns a
> NaN).
[snip]
> My interpretation is that the result returned for +-Inf should have the same
> sign, i.e.: +0 for +Inf, -0 for -Inf.

My previous patch would also return +0 for negative finite integers and
NaNs.  This should do better (but it's completely untested):

Index: modfl.S
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/ansi/math/modfl.S,v
retrieving revision 1.1
diff -c -r1.1 modfl.S
*** modfl.S	25 Nov 1994 19:59:40 -0000	1.1
--- modfl.S	29 Sep 2003 10:08:25 -0000
***************
*** 17,22 ****
--- 17,40 ----
  	fldcw -2(%ebp)
  	fld %st(0)
  	fstpt (%eax)
+ 	fucom %st(1)
+ 	fnstsw -2(%ebp)
+ 	movw -2(%ebp),%dx
+ 	andb $0x44,%dh
+ 	xorb $0x40,%dh
+ 	jnz 0f
+ 	fxam
+ 	fnstsw -2(%ebp)
+ 	fstp %st(0)
+ 	fstp %st(0)
+ 	fldz
+ 	movw -2(%ebp),%dx
+ 	andb $0x02,%dh
+ 	jz 1f
+ 	fchs
+ 	jmp 1f
+ 0:
  	fsubrp %st,%st(1)
+ 1:
  	leave
  	ret


-- 
Esa Peuha
student of mathematics at the University of Helsinki
http://www.helsinki.fi/~peuha/

- Raw text -


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