Think of something that you wish Authorware could do but it doesn't?  Let the our good friends at Macromedia know via the wishlist.

Please let us know if you find any of the materials on this site inappropriate or offensive. Please include the url and why the material should be reviewed.

Comments and questions about the site are also welcome. Please no Authorware questions, use the AWARE list.

Back

B7010 - How do I get the Max function to return the real value?

by - Joseph Ganci


I used the Max(AnyList) function to return the highest value in a list of real numbers. Only it returns the integer portion. Why is this and how can I get it to return the real value?

Interesting problem. The definition for max() gives no indication that it only works with integers. Ah, well, whenever I find an apparent bug, I try to find a workaround.

Assuming that your numbers are limited to two decimal places (as with dollars and cents, the following code should give you a clue as to how to accomplish what you need to do:

list := [23.24, 5643.22, 3.89]
list2 := CopyList(list)
repeat with i := 1 to ListCount(list)
  list2[i] := list2[i] * 100
end repeat
max := Max(list2) / 100

The first list contains three numbers. List2 is a copy of list so you can manipulate it. Every value in the list is multiplied by 100 to make it an integer. The variable max then finds the maximum value and divides it by 100 to get it back to the original value. If your decimal value can be longer than 2 digits, you will have to  manipulate the 100 value above to accommodate the lowest significant digit.

There are 0 reviews
Add your review
Back