Re: How to find the greatest of two numbers without using thecomparison operators?



If you didn't need to use the IF statement, I can think of a number of
(ridiculously expensive) ways to do it. (I was thinking of these when I wasn't
looking at the original assignment where we knew the items were numeric)

- Create a temp file and SORT it
- Create an indexed file (and see what entry you get first)
- Put them into a table and use SEARCH (I am not even certain this could work)

And then there is my favorite (that actually meets the original assignment)

- use Object Orientation and create a method for comparing two items, e.g.

If whatever::"compare" (Field-A Field-B) Numeric
Then Display "Field-A > Field-B)


.... where the compare method returns zero if the first operand is > than the
second
it returns spaces if the 2nd operand is > than the first
- it returns high-values if they are equal (so you would need to do a 2nd test)

***

Don't you think THAT would impress the teacher <G>

--
Bill Klein
wmklein <at> ix.netcom.com
"Rick Smith" <ricksmith@xxxxxxx> wrote in message
news:13dggs41m0sc4c@xxxxxxxxxxxxxxxxxxxxx

"Frank Swarbrick" <Frank.Swarbrick@xxxxxxxxxxxxxx> wrote in message
news:46D7E17F.6F0F.0085.0@xxxxxxxxxxxxxxxxx
[snip]
Not sure why you need this, but perhaps FUNCTION MAX could give you what
you
want?

COMPUTE MAX = FUNCTION MAX(A B)

Another intereting approach might be:
-----
evaluate
function ord-max(A B) - function ord-min(A B)
when 1
display "A is less than B"
when 0
display "A is equal to B"
when -1
display "A is greater than B"
end-evaluate
-----

A and B may be either numeric or alphanumeric, as long as
they are the same.





.



Relevant Pages

  • Re: display users in group
    ... i have a strange question... ... i copied passwd file to temp file. ... from the temp file i need to get group id of each user. ... it should display only users in the group. ...
    (comp.unix.aix)
  • display users in group
    ... i have a strange question... ... i copied passwd file to temp file. ... from the temp file i need to get group id of each user. ... it should display only users in the group. ...
    (comp.unix.aix)