This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug middle-end/23195] [4.0/4.1 Regression] Using frexp with fabs produces negative result


------- Additional Comments From reichelt at gcc dot gnu dot org  2005-08-02 12:30 -------
I don't think that libm is broken. I think the man page is just inaccurate.
I just tried on IRIX and they also return negative results for a negative
argument.

> DESCRIPTION
>        The frexp() function is used to split the number x  into  a  normalized
>        fraction and an exponent which is stored in exp.

>From this I'd expext that if I put the result and the exponent back together
I'll end up with the original number (that's my interpretation of "split").

> RETURN VALUE
>        The  frexp() function returns the normalized fraction.  If the argument
>        x is not zero, the normalized fraction is x times a power of  two,  and
>        is always in the range 1/2 (inclusive) to 1 (exclusive).  If x is zero,
>        then the normalized fraction is zero and zero is stored in exp.

However this section doesn't talk about the sign. The normalized part is
positive here, contradicting the stuff above. So I think that the man page
is just inaccurate.

I think the right fix is to move "CASE_BUILTIN_F (BUILT_IN_FREXP)"
into the following section:

	      /* True if the 1st argument is nonnegative.  */
	      return tree_expr_nonnegative_p (TREE_VALUE (arglist));


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23195


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]