Solo week 3일차

Gong Intaek·2021년 2월 21일
0

코드스테이츠

목록 보기
38/151
post-thumbnail

TIL

XOR( ^ )

(동기 분들 블로그 순회하다가 발견. 연관된 리트코드의 문제도 같이 얻고 어디선가 본것은 같지만 기억은 나지 않으므로 적음.)

Performs the XOR operation on each pair of bits. a XOR b yields 1 if a and b are different. The truth table for the XOR operation is:

aba XOR b
000
011
101
110
     9 (base 10) = 00000000000000000000000000001001 (base 2)
    14 (base 10) = 00000000000000000000000000001110 (base 2) 
14 ^ 9 (base 10) = 00000000000000000000000000000111 (base 2) = 7 (base 10)

Bitwise XORing any number x with 0 yields x.

Bitwise XORing any number x with -1 yields ~x.

비트 논리 연산자 중 하나 (and(&), or(|), xor(^), not(~))

비트 논리 연산자는 다음과 같이 사용됩니다.

피연산자는 32비트 정수로 변환되고, 이진법으로 표현됩니다 (0과 1).
이진법으로 표현된 첫 번째 피연산자는 두 번째 피연산자와 쌍을 이룹니다: 첫 번째는 첫 번째 비트끼리, 두 번째는 두 번째 비트끼리...
연산자는 각각의 비트쌍에 적용되고, 결과 또한 이진법으로 구성됩니다.

 9 (base 10) = 00000000000000000000000000001001 (base 2)
-9 (base 10) = 10000000000000000000000000001001 (base 2)

첫번째 숫자는 부호를 의미 0 => +, 1 => -

abandorxor
00000
01011
10011
11110

not(~)

Performs the NOT operator on each bit. NOT a yields the inverted value (a.k.a. one's complement) of a. The truth table for the NOT operation is:

aNOT a
01
10
9 (base 10) = 00000000000000000000000000001001 (base 2)
~9 (base 10) = 11111111111111111111111111110110 (base 2) = -10 (base 10)

Bitwise NOTing any number x yields -(x + 1). For example, ~5 yields -6.

추가적인 비트 연산자 시프트 연산자

  • << (Left shift)

    This operator shifts the first operand the specified number of bits to the left. Excess bits shifted off to the left are discarded. Zero bits are shifted in from the right.

    For example, 9 << 2 yields 36:

        9 (base 10): 00000000000000000000000000001001 (base 2)
    9 << 2 (base 10): 00000000000000000000000000100100 (base 2) = 36 (base 10)

    Bitwise shifting any number x to the left by y bits yields x * 2^y.

  • >> (Sign-propagating right shift)

    This operator shifts the first operand the specified number of bits to the right. Excess bits shifted off to the right are discarded. Copies of the leftmost bit are shifted in from the left. Since the new leftmost bit has the same value as the previous leftmost bit, the sign bit (the leftmost bit) does not change. Hence the name "sign-propagating".

    For example, 9 >> 2 yields 2:

         9 (base 10): 00000000000000000000000000001001 (base 2)
    9 >> 2 (base 10): 00000000000000000000000000000010 (base 2) = 2 (base 10)

    Likewise, -9 >> 2 yields -3, because the sign is preserved:

        -9 (base 10): 11111111111111111111111111110111 (base 2)
    -9 >> 2 (base 10): 11111111111111111111111111111101 (base 2) = -3 (base 10)
  • >>> (Zero-fill right shift)

    This operator shifts the first operand the specified number of bits to the right. Excess bits shifted off to the right are discarded. Zero bits are shifted in from the left. The sign bit becomes 0, so the result is always non-negative.

    For non-negative numbers, zero-fill right shift and sign-propagating right shift yield the same result. For example, 9 >>> 2 yields 2, the same as 9 >> 2:

          9 (base 10): 00000000000000000000000000001001 (base 2)
    9 >>> 2 (base 10): 00000000000000000000000000000010 (base 2) = 2 (base 10)

    However, this is not the case for negative numbers. For example, -9 >>> 2 yields 1073741821, which is different than -9 >> 2 (which yields -3):

         -9 (base 10): 11111111111111111111111111110111 (base 2)
    9 >>> 2 (base 10): 00111111111111111111111111111101 (base 2) = 1073741821 (base 10)

동기분들의 학습량이 넓고 깊다.

  • 나는 어떻게 준비해야할지 모르겠다는걸 깨달았다.

생각 이상으로 체력 저하가 심하다.

  • 단순한 산책에도 버거움이 느껴지는 듯 했다. 꾸준한 운동이 필요하다. 손발 저림이 신경성 문제만은 아닌듯 하다.

오늘 한 일

  • 리트코드 문제 풀기 하나
  • 간단한 산책
  • 블로그 순회

오늘은...

일어나서 블로그 순회후 동기분들의 학습량과 학습범위와 깊이에 크게 놀란후 오래만의 산책이후 체력 저하가 극심함을 느끼며 운동의 필요성을 느낌 이후 추가적인 운동시간확보의 필요성을 여실하게 느끼고 동기분들의 학습량과 깊이 범위에 대해 나는 어찌해야 할까 고민하였으나 딱히 좋은 해결책은 생각나지 않음. 목표가 있으면 좋겠다라는 생각이 들긴함. 결론은 이후 주어진것에 충실하자가 전부 블로그 형식의 개선 필요성을 느꼈으나 아직은 개선 방향이 딱히 잡히지는 않음. 한동안은 형식이 오락가락 할것으로 예정

profile
개발자가 되기위해 공부중

0개의 댓글