[futurebasic] Re: [FB] re: USING bug with -0.000 input

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : June 2011 : Group Archive : Group : All Groups

From: Robert Purves <listrp@...>
Date: Tue, 7 Jun 2011 09:52:46 +1200
Walter Lenk wrote:
> The external fix that I am using is:
> IF (result2 == -0.00) THEN LET result2 = result2 * -1

In the IEEE754 standard -0.0 is required to compare equal to 0.0.
Thus your workaround for the FB5 formatter bug could be written in the strange-looking but effective form:
    if ( result2 == 0.0 ) then result2 = 0.0 // change -0.0 to 0.0

> And this could easily be incorporated in the PSusing() routine at
> the beginning, where it determines whether the number is negative.
> A simple change of
> 	if ( n < 0.0 )
> to
> 	if (( n < 0.0 ) OR ( n == -0.00))
> would seem to do the job - please pardon my lack of understanding of C syntax, but I think you get the idea.


No, that would cause both 0.0 and -0.0 to be treated as negative. The correct fix for build_goodies/General.c: PSusing() is
    if ( copysign( 1.0, n ) < 0.0 )
      {  ...  }
and this will be in the next release.

Can I ask how your program comes to encounter -0.0? 
AFAIK, signed zero is useful only in the context of complex arithmetic, where it allows branch cuts to be handled.

Robert P.