[thelist] Programming - Finding Largest Value

bread_man bread_man at hotmail.com
Wed Mar 20 15:27:01 CST 2002


> What datatypes are the values of your variables? If they're all
> numbers, that should do fine.

Thanks all for your replies.  The logic of the function was fine.
Debugging, I found that the value assigned to the biggest variable was 8,
even though I know that the highest value was 10.  Reason?  They were being
compared as strings, and not numbers.  As a string, 8 is greater than 10!
Whoops.

Thanks for your help!

bread_man

> >_level0.biggest = _level0.var1
> >
> >for (i=1; i<9; i++) {
> >     if (_level0["var" + i] > _level0.biggest) {
> >     _level0.biggest = _level0["var" + i];
> >     }
> >}
> >
> >The script isn't returning the correct value for the variable
> >"biggest."  I'm sure the same logic applies to any language, could
> >someone tell me why this function doesn't work?





More information about the thelist mailing list