Re - run on build 409 and 419 Vista HB. The result : 9 - 10 - 8 - 0 - 0 - 9 - 11 - 10 - 11 - 8. Did you expect the result should be : 9 - 10 - 8 - 7 - 0 - 2 - 11 - 3 - 4 - 1 ?, because if it is, I should delete my previous comment then and also now I don't understand it too, which is good because I don't have to answer question :)
But if you need return of exact value and strict existence there is no -1 return code.
From text:" If the element with the specified value doesn't exist in the array, the function returns the index of the nearest smallest value of the elements between which the searched value is located."
In that case you need to write your own search task.
Efficient searching in sorted arrays. iBarShift probably implimented via ArrayBsearch(Time, ...)
OK get it - sort of :). I never use ArrayBsearch(), and probably don't understand the English meaning of "Binary" :(. So that will make ArrayBsearch is ArrayBinarySearch . I guess philw can not use this and have to write the code to search it manually like he finally did :(.
But if you need return of exact value and strict existence there is no -1 return code.
From text:" If the element with the specified value doesn't exist in the array, the function returns the index of the nearest smallest value of the elements between which the searched value is located."
In that case you need to write your own search task.
i'm looking for the exact value in an array and if not found, return -1
whats1thingnow: i'm looking for the exact value in an array and if not found, return -1 anyone have an example of how to do this?
If the array is sorted,
int index = ArrayBsearch(array,value);
if(array[index] == value) return index;
return EMPTY;
Otherwise
for(int index = ArraySize(array); index > 0;){ --index;
if(array[index] == value) return index;
}
return EMPTY;
Was that so hard you couldn't even try? Next time Show us your attempt (using the CODE button) and state the nature of your problem. No free help 2017.04.21
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Re - run on build 409 and 419 Vista HB. The result : 9 - 10 - 8 - 0 - 0 - 9 - 11 - 10 - 11 - 8. Did you expect the result should be : 9 - 10 - 8 - 7 - 0 - 2 - 11 - 3 - 4 - 1 ?, because if it is, I should delete my previous comment then and also now I don't understand it too, which is good because I don't have to answer question :)
Think we found bug :(
But if you need return of exact value and strict existence there is no -1 return code.
From text:" If the element with the specified value doesn't exist in the array, the function returns the index of the nearest smallest value of the elements between which the searched value is located."
In that case you need to write your own search task.
WHRoeder:
You should get 4, 6, 2, 0, 1, 5, 8, 7, 9, 3. from ArrayBSearchIt's not a bug in mt4. It is a bug in YOUR code. When you sort array_b to
Yes I get that value from both build 409 and 419. However, that is a sorted Array_B, and in this case phillw does not sort Array_B.
What is the use of ArrayBsearch anyway ???
Yes I get that value from both build 409 and 419. However, that is a sorted Array_B, and in this case phillw does not sort Array_B.
What is the use of ArrayBsearch anyway ???
OK get it - sort of :). I never use ArrayBsearch(), and probably don't understand the English meaning of "Binary" :(. So that will make ArrayBsearch is ArrayBinarySearch . I guess philw can not use this and have to write the code to search it manually like he finally did :(.
Thanks WHRoeder but no thanks for this.
But if you need return of exact value and strict existence there is no -1 return code.
From text:" If the element with the specified value doesn't exist in the array, the function returns the index of the nearest smallest value of the elements between which the searched value is located."
In that case you need to write your own search task.
i'm looking for the exact value in an array and if not found, return -1
anyone have an example of how to do this?
No free help 2017.04.21
Or pay someone. Top of every page is the link Freelance.
Hiring to write script - General - MQL5 programming forum 2018.05.12