Jump to content

How to get max value


h3x3r
Go to solution Solved by Rabatini,

Recommended Posts

  • Engineer

As title says. I have an array of uint16 values and I need get the highest one. Can someone please help me. Preferably for 010 Hex Editor.  Thank you!

There is function > 

double Floor( double x)


which returns the highest integer less than or equal to x.

But it always return last Index value instead of highest one.

 

Anyway this is code for parsing values.
 

local uint32 Count=50;
struct {
    uint16 Index;
}Buffer[Count]<optimize=false>;

 

Link to comment
Share on other sites

  • Engineer
  • Solution

Try something like that.

 

local uint32 Count = 50;
struct {
    uint16 Index;
} Buffer[Count] <optimize=false>;

local uint16 maxValue = 0;  // Initialize max value
local uint32 i;            // Loop counter

// Iterate through the Buffer array
for (i = 0; i < Count; i++) {
    if (Buffer[i].Index > maxValue) {
        maxValue = Buffer[i].Index;
    }
}

// Output the maximum value
PrintF("The highest value is: %u\n", maxValue);

 

  • Thanks 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...