Shop OBEX P1 Docs P2 Docs Learn Events
Help - Compute Max Value? — Parallax Forums

Help - Compute Max Value?

edited 2012-02-18 10:32 in Propeller 1
Hello.

Anyone know how to compute the Max value of two numbers, similar to "c" language function?
ex. MaxValue := Max(Val1, Val2).

Assembler is over my head.

Thanks.
otis

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-02-18 09:58
    Welcome to the Parallax forum, Otis! Here's the way to do the max operation in Spin:
    MaxValue := Val1 #> Val2

    If you want to accumulate a maximum from a sequence of data reads, for example, there's also an assignment version:
    MaxValue #>= Val

    Just remember that all math in Spin is signed, including the comparisons that #> and <# (the "min" operator) perform internally.

    -Phil
  • edited 2012-02-18 10:32
    Phil,

    Thanks very much for the quick response, wow!
    Works great!

    Regards,
    otis
Sign In or Register to comment.