3 ms·
About the title: "Ternary logic" usually means "logic with three truth values". But this piece covers a compiler instruction which handles all binary logic gate
by cubefox 2y ago
About the title: "Ternary logic" usually means "logic with three truth values". But this piece covers a compiler instruction which handles all binary logic gates with three inputs.
- dzaima 2y agoThe x86 instruction is named 'ternlog', and intrinsic - 'ternarylogic' though; while perhaps unfortunate, the title is appropriate. (and even then 'bitwise' already sort of takes place of what 'ternary'-as-three-valued would, and 'ternary' is also very often three-input, so much so that 'a ? b : c' is often called the ternary operator (and in fact ternlog can simulate this ternary operation; and in fact the article is even about exactly that))
- cubefox 2y agoYeah, though the article describes 0xE2, which is 'b ? a : c'. 'a ? b : c' would be 0xCA.
- someguydave 2y agoAgree, I was also confused on this point. I guess the name “evaluate a three term binary expression” is less snappy though.
- cubefox 2y agoI'm also not sure what was "busted" here.
- eapriv 2y agoIt’s “ternary (logic instruction)”, not “(ternary logic) instruction”.
- orlp 2y agoThat's not what ternary refers to here. In C, '+' is a binary operator because it accepts two inputs. '?:' is a ternary operator because it accepts three inputs. It is usually referred to as the ternary operator because it is unique in C, but there's nothing fundamental about that. vpternlogd implements all bitwise ternary operators - those operators that accept three inputs.
- dahart 2y agoWhat’s logic with three truth values? Are you thinking of trinary and not ternary? I think of a ternary expression as one of the form “(a < b) ? 5 : 2” and that seems like the most common usage from a C++, JavaScript, and Python perspective. https://www.programiz.com/cpp-programming/ternary-operator https://www.programiz.com/cpp-programming/ternary-operator OTOH, it doesn’t matter what assumptions we make, right? Words and phrases often have multiple meanings. The word ternary means composed of three parts, and that fits here.
- wildzzz 2y agoTernary is the right word. Ternary numbers or logic have 0,1,2 or true, false, and something else. Ternary functions just have three arguments that could be binary logic, similar to a second order polynomial. Ternary comes from the Latin root word ternarius (composed of three things) which contains the root word ter- or tern- which is an adverb variation of the original root terti- meaning 3rd. Same with binary, it comes from the adverb variation bi- or bin- meaning second. Bi- being derived from the original Greek dy- or di-. However, ternary is more correct than trinary because in the binary, we are not using the Latin root for the cardinal two, duo-. We use the adverb version of two, bi-. Trinary just sounds better to some people because tri- and bi- rhyme. For a numerical system composed of four components, we use quarternary which also uses the adverb form of 4, quarter(n)-, instead of the cardinal form, quadr(i)-. Personal opinion, saying trinary makes you sound like you don't have any formal education.
- dahart 2y agoHaha don’t get me started! And people who say ‘base 3’ and 3-ary sound like complete morons. You’re right; ternary is totally valid and does seem more common now that I look it up. Trinary is a valid synonym, and in the dictionary, and mentioned in the Wikipedia for ternary, and was in fact used by many people during my formal education. Your personal opinion sounds like it’s rather presumptuous, not correct, and designed to start a fight. You have the right to keep it to yourself… or change your mind.