×
The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.
Vinay,
A binary search is exactly what %lookup does. For that algorithm to work correctly, you must ensure that the table or array is sorted properly.
See:
https://www.rpgpgm.com/2015/09/when-lookup-ne-lookup.html
Excerpt from the above article below:
Referring to IBM's KnowledgeCenter I found a link at the bottom of the %LOKUPxx page that took me to a page called: Sequenced arrays that are not in the correct sequence ... an interesting passage on this page states:
... the %LOOKUPxx built-in functions and the LOOKUP operation code may find different values. The %LOOKUPxx built-in functions may not find a data value even if it is present in the array.
Since a binary search is used by the %LOOKUPxx built-in functions for a sequenced array, and the correct function of a binary search depends on the data being in order, the search may only look at a few elements of the array. When the array is out of order, the result of a binary search is unpredictable.
See:
- %LOOKUPxx BIF
- LOOKUP Operation code
- Sequenced arrays that are not in the correct sequence
See also:
http://www.itjungle.com/fhg/fhg020409.html
Hope that helps,
Mark S. Waterbury
On Friday, December 2, 2022 at 09:25:54 AM EST, Vinay Gavankar <vinaygav@xxxxxxxxx> wrote:
Hi,
Is there a way to define a "sequenced" keyed array data structure, so that
the system uses Binary Search when doing a %lookupxx on it using the key?
TIA
Vinay
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact
[javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.