Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 19:25 17 Nov 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : CMM2 - MATH(MAX(A())

Author Message
Nimue

Guru

Joined: 06/08/2020
Location: United Kingdom
Posts: 425
Posted: 03:46pm 25 Feb 2021
Copy link to clipboard 
Print this post

Using the above I can return the maximum of the array.

Is there a clever way to find the index of said maxium.

Ie:

a(0) = 10
a(1) = 12
a(2) = 9
a(3) = 3

Math(Max(a()) will give me 12.   How can I return index  (1) for that without comparing every value in the array to this max?

edit>>> I could sort the array and return the first element  >> presumably quicker that me coding the comparision.

Off to try.

Got it >>> SORT array() [,indexarray()]    << use the index array.

Cheers
N
Edited 2021-02-26 02:00 by Nimue
Entropy is not what it used to be
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025