[R-gregmisc-users] SF.net SVN: r-gregmisc:[1766] trunk/gtools/R/binsearch.R
Brought to you by:
warnes
From: <wa...@us...> - 2014-01-14 15:56:46
|
Revision: 1766 http://sourceforge.net/p/r-gregmisc/code/1766 Author: warnes Date: 2014-01-14 15:56:41 +0000 (Tue, 14 Jan 2014) Log Message: ----------- Fixed bug where binsearch() returned the wrong endpoint & value when the found value was at the upper endpoint. Modified Paths: -------------- trunk/gtools/R/binsearch.R Modified: trunk/gtools/R/binsearch.R =================================================================== --- trunk/gtools/R/binsearch.R 2014-01-13 18:16:51 UTC (rev 1765) +++ trunk/gtools/R/binsearch.R 2014-01-14 15:56:41 UTC (rev 1766) @@ -51,7 +51,7 @@ cat("fun(center)=",val,"\n") } - + if( val==target ) { val.lo <- val.hi <- val @@ -75,9 +75,9 @@ cat("new hi=",hi,"\n") cat("--------------\n") } - + } - + # Create return value retval <- list() retval$call <- match.call() @@ -116,8 +116,8 @@ else if( val.hi==target ) { retval$flag="Found" - retval$where=lo - retval$value=val.lo + retval$where=hi + retval$value=val.hi } else { @@ -125,10 +125,10 @@ retval$where=c(lo, hi) retval$value=c(val.lo, val.hi) } - + return(retval) } - - + + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |