There are several different ways, for example I did this:You‘re implying that True „equals“ to 1 (the integer-cast)
Result:=Integer(key1>key2)-Integer(key1<key2);
There are several different ways, for example I did this:You‘re implying that True „equals“ to 1 (the integer-cast)
Result:=Integer(key1>key2)-Integer(key1<key2);
Is this always the case? Or might True result to -1?
However, if this is an operator with one input variable, then it doesn’t matter, it’s just Sign ()No it isn't. Zero is ambiguous by nature. Zero can be minus zero which is just as valid. From a computer science pov this really matters.
Depends on the taskHowever, if this is an operator with one input variable, then it doesn’t matter, it’s just Sign ()No it isn't. zero can be minus zero. From a computer science pov this really matters.
What you propose is only half a solution. See my code.
Depends on the taskNo it depends on a thorough understanding of the theory.
There are several different ways, for example I did this:You use ord to convert Boolean to integer.
Result:=Integer(key1>key2)-Integer(key1<key2);
You‘re implying that True „equals“ to 1 (the integer-cast)Yes, Boolean is simply an enumeration data type, so
Is this always the case? Or might True result to -1?
would sign function not work?Yes, I would have mentioned that, too.
https://www.freepascal.org/docs-html/rtl/math/sign.html
It returns -1 if a<b, returns 0 if a=b and returns 1 if b>a. […] I think there is not a predefined operator at the moment?There is actually math.compareValue (https://www.freepascal.org/docs-html/rtl/math/comparevalue.html) doing just what you want.
But that is already used and what I showed.... See the Rosetta code entry.What are you trying to say Thaddy, that you and only you have the proper theory?
{ imp ==>}
operator >< (const a,b:trit):trit;
Problem with this thread is that there is too much noise.
(And frankly people writings not based on any theory at all. My code is founded in proper theory and complete)
That operator can ONLY return a trit, which means -1,0,+1..... and at a guess, implemented and validated (confirmed to work) a gazillion times all across the world and programming languages
I never villified you, I merely was trying to teach you how it can be done.
(From two different approached, but founded in the Kleene and Priest logic, which is the accepted and current scientific approach to solve the problem at hand)