Quantcast
Channel: Answers by "Narv"
Viewing all articles
Browse latest Browse all 60

Answer by Narv

$
0
0
I'm not sure I understand your issue because it seems to be correctly doing what you want... It is stuck on 15 in this case because you had max at 16 and min at 14 so your next guess would have put it at 15 min max 16... so the middle would be 15.5 but since you are using an int it is truncated. Tracing your logic from the output it seems to be the following: since you're at 125, you clearly hit DOWN for lower at first.. so it went to 1 - 500 so picked 250... so hit DOWN again and it went to 1 - 250 so picked 125. hit DOWN again so 1 - 125 so picked 62.5 but since it's an int rounded to 63. Hit DOWN so 1 - 63 so picked 31.5, rounded to 32. hit DOWN again so 1 - 32 and picked 16. You hit DOWN again and it went 1 - 16 so it picked 8. then you hit UP so it went 8 - 16 and picked 12. you hit UP so it went 12 - 16 and picked 14. you hit UP so it went 14 - 16 and picked 15... now you hit UP again instead of telling that it picked right since it picked 14 15 and 16 for you. so you're lying to the poor computer.. but if you hit UP you got 15 - 16.. which would pick 15.5 and it rounded it to 15. and if you hit DOWN it would go 15 - 16 and repeat, and up would be 15-15 and stuck.. I'm not seeing an error. What number did you intend because this is what you got from your code..

Viewing all articles
Browse latest Browse all 60

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>