News:

  • June 26, 2026, 04:25:32 AM

Login with username, password and session length

Author Topic: Compare multiple numbers  (Read 12308 times)

Bobby

  • Sr. Member
  • ****
  • Posts: 60
Compare multiple numbers
« on: June 01, 2017, 08:13:29 AM »
Hey all,

Trying to find an easy way to determine from 4 different values which is greater. Feel like there should be an easy way but not seeing it.


Thanks!

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6161
  • Yes Pinky, Do-more will control the world!
Re: Compare multiple numbers
« Reply #1 on: June 01, 2017, 08:26:01 AM »
Hey all,

Trying to find an easy way to determine from 4 different values which is greater. Feel like there should be an easy way but not seeing it.


Thanks!

MATH D10 = maxr(D0, 4)
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

Bobby

  • Sr. Member
  • ****
  • Posts: 60
Re: Compare multiple numbers
« Reply #2 on: June 01, 2017, 08:34:54 AM »
I figured there was an easy way! Thanks!

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3827
    • Host Engineering
Re: Compare multiple numbers
« Reply #3 on: June 01, 2017, 10:14:04 AM »
I figured there was an easy way! Thanks!
There are a TON of cool functions in the MATH block, but since it is a free-form editor (for now), no one knows what goodies are in there.  The MATH Help Topic DMD0085 spells them all out.  Here's a screen shot of that list (MAXR is under the Statistical group).  Let us know if we can add any that might be helpful.


Mike Nash

  • Hero Member
  • *****
  • Posts: 652
Re: Compare multiple numbers
« Reply #4 on: June 01, 2017, 10:26:33 AM »
I don't need it yet, but how about returning the first or last offset from a MAXR type operation on a range of locations? I am asking to know that say the 5th element is the largest value, so I can use that to reference related values in other ranges with that offset.

 

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3827
    • Host Engineering
Re: Compare multiple numbers
« Reply #5 on: June 01, 2017, 11:25:35 AM »
I don't need it yet, but how about returning the first or last offset from a MAXR type operation on a range of locations? I am asking to know that say the 5th element is the largest value, so I can use that to reference related values in other ranges with that offset.
That is a great idea.  We would probably make that be an actual instruction, since MATH is meant to generate 1 result (not multiple output parameters).  We want to add Table/Statistical instructions, and this would be great as part of that set of instructions.


Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3609
  • Darth Ladder
Re: Compare multiple numbers
« Reply #6 on: June 01, 2017, 11:55:31 AM »
Or do it in two steps.  Do a series of FINDRxx() [FINDREQ, FINDRGE, FINDRLT, etc.] functions that take (range, value) and return an index to the first element that satisfies the test.  Those would be useful functions on their own, and used with the output of MAXR(), would give the index to the max value in the range.  Maybe include a user-definable equality window for reals.
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

Garyhlucas

  • Hero Member
  • *****
  • Posts: 421
Re: Compare multiple numbers
« Reply #7 on: June 01, 2017, 02:55:54 PM »
Not to get off topic but the Rockwell Software salesmen were in our offices this morning and it was a pleasure telling them how glad I am NOT to be using their product anymore! The guy mentions that they have 84% of our market. I said that I was aware of that, and if a customer says they want AB then our response is "Then we won't sell you our product, sorry"

In 12 years of using AB I've never spoken to anyone actually involved with making AB and in this forum you guys listen to what we say and we actually see it show up in your products! Freaking AWESOME!

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3609
  • Darth Ladder
Re: Compare multiple numbers
« Reply #8 on: June 01, 2017, 03:04:39 PM »
Yeah, but if they're measuring the 84% by dollar value of the PLC's, that might only be three systems a year!   ;D
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.