본문 바로가기
728x90
반응형

operator3

[Py] Bitwise Operator Operand로 int 와 bool , 또는 bytes와 bytesarrays의 각 요소 (각 요소가 중요!!)만 사용할 수 있다.bytes 나 bytearrays는 직접 사용이 안되고 각 요소 단위로 꺼내서 처리해야 한다.참고로,Bitwise Operator는 Tensor 등에서 Element-wise로 동작하며 때문에 그 중요도가 커짐.그 외에선 많이 쓰이진 않음. Python의 Bitwise Operators의 우선순위와 동작은 다음과 같음(이해를 위해 8비트 기준으로 기재했으나 실제로는 Python의 int는 가변 길이 정수로 비트 수에 제한이 없다는 점을 명심) Bitwise Operator를 연산자 precedence 에 따라 기재함:1. ~ (비트 NOT, complement)각 bit를 .. 2025. 3. 26.
[Python] Binary Bitwise Operations Python의 binary bitwise operoator는 다음과 같음. 표에서 binary result부분은 다음과 같은 x, y 에서의 결과임.x : 0b0101 ( = 5 )y : 0b0001 ( = 1)OperatorDescriptionExampleDecimal resultBinary result&Andx & y10b0001|Orx | y50b0101^Exclusive Orx ^ y40b0100~Flip bits~x-6binary representation depends on int sizeLeft shiftx 100b1010>>Right shiftx >> 120b0010 Note : Flip bits (not 연산)https://dsaint31.me/mkdocs_site/CE/ch01/nega.. 2024. 1. 15.
[Python] Boolean Operators, Relational Operators, Membership Operators and Identity Operator https://dsaint31.tistory.com/516 -(negation) > * = / = // = % > + = -(subtraction) Lower우선순위를 기억하는 것도 중요하지만, 헷갈리면 그냥 parentheses로 묶어주면 된다. (가독성을 위해서도 " data-og-host="dsaint31.tistory.com" data-og-source-url="https://dsaint31.tistory.com/516" data-og-url="https://dsaint31.tistory.com/516" data-og-image="https://blog.kakaocdn.net/dna/7urm4/hyYJpttqvF/AAAAAAAAAAAAAAAAAAAAAD3tJ-IbNBmNtAyR6cvVwx7D-IJPuVet4lXt64ESt_k_/img.png?credential=yqXZFxpELC7KVnFOS48ylbz2pIh7yKj8&expires=1780239599&allow_ip=&allow_referer=&signature=LdPSjXTx900xTEBpWmFz4C1wxJ0%3D 2023. 7. 28.
728x90
반응형