Bit Manipulation in Python: Is Nth Bit Set?

Опубликовано: 20 Апрель 2018
на канале: LucidProgramming
10,747
145

In this video, we will write a program that takes an integer and tests whether the n-th bit in the binary representation of that integer
is set or not.

For instance, the binary representation of 6 is:
110

The least significant bit is the bit on the far right
of the binary representation and the most significant
bit is the bit on the far left. We order the bits as

b2, b1, b0
1 1 0

For our function, if we check the 0th bit, we should obtain
"False" as the binary value at b0 is 0.

Alternatively, if we check the 1st bit, we should obtain
"True" as the binary value at b1 is 1.

This video builds on the idea present in the following video, where we used bit manipulation to determine if a given number is even or odd:
   • Bit Manipulation in Python: Is Even or Odd?  

This video is part of a series on bit manipulation:
http://bit.ly/lp_bitmanip

The software for this video can be found on my Github page:
https://github.com/vprusso/youtube_tu...

Do you like the development environment I'm using in this video? It's a customized version of vim that's enhanced for Python development. If you want to see how I set up my vim, I have a series on this here:
http://bit.ly/lp_vim

If you've found this video helpful and want to stay up-to-date with the latest videos posted on this channel, please subscribe:
http://bit.ly/lp_subscribe


На этой странице сайта вы можете посмотреть видео онлайн Bit Manipulation in Python: Is Nth Bit Set? длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь LucidProgramming 20 Апрель 2018, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 10,747 раз и оно понравилось 145 зрителям. Приятного просмотра!