mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-12-20 07:30:26 +00:00
precision in binsearch
This commit is contained in:
parent
9c29f39f7e
commit
c8e5c3e763
4
hyper.h
4
hyper.h
@ -904,8 +904,8 @@ template <class T> void texture_order(const T& f) {
|
||||
|
||||
/** find the smallest value of x in range [dmin..dmax] such that f(x) returns true */
|
||||
|
||||
template<class T> ld binsearch(ld dmin, ld dmax, const T& f) {
|
||||
for(int i=0; i<200; i++) {
|
||||
template<class T> ld binsearch(ld dmin, ld dmax, const T& f, int iterations = 200) {
|
||||
for(int i=0; i<iterations; i++) {
|
||||
ld d = (dmin + dmax) / 2;
|
||||
if(dmin == d || dmax == d) break;
|
||||
if(f(d)) dmax = d;
|
||||
|
Loading…
Reference in New Issue
Block a user