Re: How to find the greatest of two numbers without using the comparison operators?
- From: "Pete Dashwood" <dashwood@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sat, 1 Sep 2007 11:50:19 +1200
"William M. Klein" <wmklein@xxxxxxxxxxxxxxxxx> wrote in message
news:0qXBi.233753$Bo7.185140@xxxxxxxxxxxxxxxxxxxxxxxxx
Pete,
Usually I am "amused" by DD's "do your own homework" and don't follow up
on it. However, when I first saw this question last night, it had ME
stumped. Certainly, it HAD TO BE homework (because I can't think of any
"good" reason to make this restriction in a business environment). Also,
when I was thinking about it, I was NOT looking at the original question,
so I didn't remember that the two fields were numeric. Therefore, I could
think of ways to do it with words (not symbols) and without an IF (using
intrinsic function MAX), or with only = (not > or <); but I couldn't come
up with a solution that actually met the requirement. I am glad you gave
the hint and others more on the solution.
Normally, I endorse the policy of not doing homework for people.
But sometimes, even if it IS homework, a helping hand, or a pointer in the
right direction does not go amiss.
In this case, I remembered a 19 year old trying to get to grips with the
assembler on a certain computer and to understand the whole architecture and
how it worked, at a time when computers were not part of the scenery and
embedded in the lives of all of us.
It had instructions like "CFM" (Compare for magnitude...), "CFE" (Compare
for equality).
The clues came when I looked at the Multiply and Divide instructions
(Macros) and realised they were repetitive addition and subtraction.
Then in a flash of cognition I realised that that was ALL this "wonderful"
machine could do... arithmetic. Nothing more. Everything else was derived
from that. (Later I found out more, and got to grips with the reality of
binary and Boolean operations, which at the lowest level are all that is
required. I once wrote a program (for a bet) which read cards and printed,
using ONLY Logical instructions AND, OR, NOT, and XOR...it was a good
learning experience.)
Nowadays, we've come a long way and both hardware, software, and bioware are
"smarter" than in those far off misty days... but the excitement I got from
figuring how it did it, has never been forgotten and I thought someone else
might benefit from that too.
Sadly, as is often the case today, the OP simply picked up a solution from
someone who was happy to provide it, without really bothering to think about
it.
It seems to me that thinking is no longer "fashionable" and solutions via
the line of least resistance are more the order of the day. I'm not
suggesting we should make our lives more difficult, but thought can often
lead to understanding, and understanding can often lead to wisdom. (Of
course, if you have no place for wisdom in your life then there is no real
requirement for thinking, either... For myself, I find the acquisition of
wisdom by personal growth to be a very useful survival tool... I've never
been conned in a pyramid scam, for example :-))
Around four thousand years ago, before the distractions and pressures of
modern life, TV, movies, travel, entertainment... people used to think.
(Human brains are quite well adapted for this...) They worked out the
distance from the Earth to the Sun just by sticking sticks in the sand on a
beach and observing the shadows. This calculation was correct to within 5%.
No reason for it; they weren't planning on going there, just an
"interesting" intellectual exercise.
Unfortunately, this knowledge and, much more importantly, the attitude that
nurtured it, was lost in the Dark ages and the advent of Religion, which
taught that the Universe behaved the way the Church said it did, and there
was therefore no need for people to think about it. The wise teachings of a
few enlightened people were submerged into commercializing the "Faith" and
the resulting parodies of the original teaching set us back thousands of
years in our development, and are still affecting our lives today. Even in
this "enlightened" age, when we can perform technical miracles, there are
still people prepared to kill themselves and others for the sake of their
imaginary friend, who is more powerful that anyone else's imaginary friend.
As you may have guessed, it is a quiet Saturday here.No one has driven a car
loaded with explosives into the local market, there are monarch butterflies
re-enacting the Battle of Britain around the newly arrived pink blossoms on
my nectarine tree, I can go to the shops with the certainty that my chances
of being shot are less than those of my being hit by a meteor, and the fact
that there is a Salvation Army church on the corner of my street does not
offend my Atheist sensibilities one jot or tittle. (I admire the work they
do.)
It IS possible for us to "get along".
But we need to think about it.
Pete
--
"I used to write COBOL...now I can do anything."
.
- Follow-Ups:
- Prev by Date: Re: How to find the greatest of two numbers without using thecomparison operators?
- Next by Date: Re: How to find the greatest of two numbers without using thecomparison operators?
- Previous by thread: Re: How to find the greatest of two numbers without using thecomparison operators?
- Next by thread: Re: How to find the greatest of two numbers without using the comparison operators?
- Index(es):