You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Dimitri Pourbaix (JIRA)" <ji...@apache.org> on 2011/01/19 08:32:44 UTC

[jira] Commented: (MATH-486) FastMath toRadian and toDegree don't handle large double numbers well

    [ https://issues.apache.org/jira/browse/MATH-486?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12983585#action_12983585 ] 

Dimitri Pourbaix commented on MATH-486:
---------------------------------------

What about the reciprocity of these two methods?  toDegrees(toRadian(x))==x and toRadian(toDegrees(x))==x
If you use INFINITY, you run into troubles.  If you return Double.MAX_VALUE instead, you look safer.   That does not prevent you returning INFINITY if you start with INFINITY and NaN if it is the argument of the method.

Furthermore, some consistency would help.  Why plural for degrees and singular for radian?

> FastMath toRadian and toDegree don't handle large double numbers well
> ---------------------------------------------------------------------
>
>                 Key: MATH-486
>                 URL: https://issues.apache.org/jira/browse/MATH-486
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 2.2, 3.0
>            Reporter: Sebb
>
> FastMath toRadian and toDegree don't handle very large double numbers well.
> For example, toDegrees(Double.MAX_VALUE) => NaN, but it should be INFINITY
> and toRadian(Double.MAX_VALUE) => NaN instead of the proper value
> This is because of the lines:
> {code}
> double temp = x * 1073741824.0; // == 0x40 00 00 00
> double xa = x + temp - temp; // => NaN for x large enough
> {code}
> This seems to be an attempt to split x into a large and a small part, but fails when x >= MAX_VALUE / 1073741824.0
> Not sure how to fix this

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.