How to find the smallest number in an array ?
#8

Quote:
Originally Posted by Jayse
Посмотреть сообщение
I know you fixed it already, but I would like to share this for anyone who's looking for a function like this (not expecting anything)

PHP код:
returnLowestValuearr[ ], len ) {
    new 
val 0x7FFFFFFF;
    for( new 
ilen++ ) if( arr] < val val arr];
    return 
val;

That's what Vince explained. I guess it's better to just assign the first value of the array to the variable since it will cut one cycle off the loop.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)