There are several different ways, for example I did this:Code: Pascal [Select][+][-]Result:=Integer(key1>key2)-Integer(key1<key2);
Quote from: Red_prig on November 28, 2022, 09:00:23 pmThere are several different ways, for example I did this:Code: Pascal [Select][+][-]Result:=Integer(key1>key2)-Integer(key1<key2);You‘re implying that True „equals“ to 1 (the integer-cast)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 ()
Quote from: Red_prig on November 28, 2022, 09:30:03 pmHowever, 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 task
You‘re implying that True „equals“ to 1 (the integer-cast)Is this always the case? Or might True result to -1?
would sign function not work?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?