Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Basic Powerbasic > Re: Function do...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 3 of 4 Topic 256 of 276
Post > Topic >>

Re: Function does not return correct value

by "Anonymous" <r1a@[EMAIL PROTECTED] > Oct 22, 2007 at 08:59 PM

Mucho gracias! Problem got solved.
--

"Auric__" <not.my.real@[EMAIL PROTECTED]
> skrev i melding 
news:471ce0b0$0$26461$88260bb3@[EMAIL PROTECTED]
> On Mon, 22 Oct 2007 16:59:24 GMT, Anonymous wrote:
>
>> Hello,
>>
>> In the code below the "BinarySearch" function returns 0, although
>> it is assigned a value of 8.
>> Anyone any idea?
>
> [snip]
>
>>IF Find = @[EMAIL PROTECTED]
 THEN
>> PRINT m 'm has the correct value here(8),but the function returns 0
>> BinarySearch = m
>>ELSEIF Find < @[EMAIL PROTECTED]
 THEN
>> BinarySearch i(),a,m,Find
>>ELSE
>> BinarySearch i(),m+1,b,Find
>>END IF
>
> [snip some more]
>
> You're recursing but not catching the return values from the
> recursion. Try something like this:
>
> IF Find = @[EMAIL PROTECTED]
 THEN
>    FUNCTION = m
> ELSEIF Find < @[EMAIL PROTECTED]
 THEN
>    FUNCTION = BinarySearch (i(),a,m,Find)
> ELSE
>    FUNCTION = BinarySearch (i(),m+1,b,Find)
> END IF
>
> -- 
> auric dot auric at gmail dot com
> email sent to the above address is not treated as private
> *****
> Don't demand justice; you too will be judged.
>
> -- 
> Posted via a free Usenet account from http://www.teranews.com
>
 




 4 Posts in Topic:
Function does not return correct value
"Anonymous" <  2007-10-22 18:59:24 
Re: Function does not return correct value
"Auric__" <n  2007-10-22 17:41:06 
Re: Function does not return correct value
"Anonymous" <  2007-10-22 20:59:28 
Re: Function does not return correct value
Peter Manders <news@[E  2007-10-22 20:43:57 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Jul 25 20:40:35 CDT 2008.