Matlab Java 中的“与或非”

Matlab:

Logical Operators: Short-Circuit && ||

expr1 && expr2
expr1 || expr2
1 & 256 // result is 1
1 & 255 // result is 1
   expr1 && expr2 represents a logical AND operation that employs short-circuiting behavior. That is, expr2 is not evaluated if expr1 is logical 0 (false). expr1 || expr2 represents a logical OR operation that employs short-circuiting behavior. That is, expr2 is not evaluated if expr1 is logical 1 (true).

and, &​​​​​​​

A & B
and(A,B)  
1 & 256 // result is 1
1 & 255 // result is 1 
   A & B performs a logical AND of arrays A and B and returns an array containing elements set to either logical 1 (true) or logical 0 (false).

bitand

 C = bitand(A,B)
 C = bitand(A,B,assumedtype)
 1 & 256 // result is 0
 1 & 255 // result is 1

Java:

& && | ||都是位操作

1 & 256 // result is 0
1 & 255 // result is 1

参考:
https://www.mathworks.com/help/matlab/ref/logicaloperatorsshortcircuit.html
https://www.mathworks.com/help/matlab/ref/and.html
https://www.mathworks.com/help/matlab/ref/bitand.html?s_tid=doc_ta
https://stackoverflow.com/questions/5564410/difference-between-and

你可能感兴趣的:(Matlab)