Forum > General
three-way comparison
Red_prig:
--- Quote from: Zvoni on November 28, 2022, 09:14:37 pm ---
--- Quote from: Red_prig on November 28, 2022, 09:00:23 pm ---There are several different ways, for example I did this:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---Result:=Integer(key1>key2)-Integer(key1<key2);
--- End quote ---
You‘re implying that True „equals“ to 1 (the integer-cast)
Is this always the case? Or might True result to -1?
--- End quote ---
Can't speak for all architectures and pascal specs, but this at least works correctly on x86
Thaddy:
Posts crossed. Plz read my reply first.
Red_prig:
However, if this is an operator with one input variable, then it doesn’t matter, it’s just Sign ()
Thaddy:
The Rosetta code entry is here:
https://rosettacode.org/wiki/Ternary_logic#Free_Pascal
Thaddy:
--- Quote from: Red_prig on November 28, 2022, 09:30:03 pm ---However, if this is an operator with one input variable, then it doesn’t matter, it’s just Sign ()
--- End quote ---
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.
What you propose is only half a solution. See my code.
Navigation
[0] Message Index
[#] Next page
[*] Previous page