Navigation Menu

Skip to content

Commit

Permalink
Checking for NaN value of "double" type has been fixed.
Browse files Browse the repository at this point in the history
A condition 
    doubleVal == Double.NaN 
will return FALSE every time.

There is an explanation at the Stackoverflow: http://stackoverflow.com/a/8819776
  • Loading branch information
alexandrklimov committed Jul 12, 2014
1 parent 06ac702 commit 2494780
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/java/in/satpathy/financial/XIRR.java
Expand Up @@ -75,7 +75,7 @@ public static double xirr( XIRRData xirrData ) {
}

System.out.println( "XIRR Result - " + result ) ;
return (result != Double.NaN) ? (result - 1) : result ;
return (Double.isNaN(result)) ? (result - 1) : result ;

This comment has been minimized.

Copy link
@yingrong

yingrong Nov 18, 2014

if result is 1.131 , it return 1.131;
if result is Double.NaN , it return NaN.

This comment has been minimized.

Copy link
@ept

ept Nov 18, 2014

Owner

I think you got the condition the wrong way round.

}

} /* End of the XIRR class. */
} /* End of the XIRR class. */

0 comments on commit 2494780

Please sign in to comment.