开发者

Why is not equal represented by ~= in Matlab?

开发者 https://www.devze.com 2023-01-18 16:20 出处:网络
This 开发者_Python百科one of the things that has always bothered me about Matlab. I understand why arrays start at 1 and not at 0 like in any other programming language, but why is != ~= in Matlab?The

This 开发者_Python百科one of the things that has always bothered me about Matlab. I understand why arrays start at 1 and not at 0 like in any other programming language, but why is != ~= in Matlab?


The tilde character (~) is generally used as the bitwise NOT operator.
As the ! character is reserved for an other usage (OS command), I guess it's not a bad choice.


In mathematical logic ~ is an old-fashioned way to write ¬


In logic tilde can mean "not", which may be confusing as in math tilde can be "equivalence" or "approx". However, it is found on more keyboards than the less ambiguous ¬. Watch out, as tilde can also mean bitwise not :)


Why is .not..eq. represented by ~= ? For the same reason that it is not represented as =!= or /= or any of the hundred and one other conventions used in programming languages.

And the twiddle, or ~, is widely used in logic texts to mean NOT.

0

精彩评论

暂无评论...
验证码 换一张
取 消