Computer Forums Doubt regarding basic python operators!

 01-21-2019, 12:57 PM #1 Solid State Member     Join Date: Dec 2018 Location: India Posts: 15 Doubt regarding basic python operators! Hello everyone, I a beginner in python programming. Many of the doubts are arising in the path of learning it. Can anyone please explain me how the bitwise NOT (~) operator works in general when doing the compilation Thanks in advance Screenshot_2019-01-21-23-26-05-025_com.microsoft.office.word.jpg __________________ __________________
 01-21-2019, 04:21 PM #2 Fully Optimized     Join Date: Dec 2016 Location: Argentina Posts: 1,684 Re: Doubt regarding basic python operators! I don't understand what you want to know. What do you mean by "when doing the compilation"? You want to understand how the low-level instructions work to flip the bits in the register? __________________ __________________ "There is nothing more animal-like than a clear conscience on the third planet of the Sun."
01-22-2019, 12:39 AM   #3
Solid State Member

Join Date: Dec 2018
Location: India
Posts: 15
Re: Doubt regarding basic python operators!

Quote:
 Originally Posted by AMD_man I don't understand what you want to know. What do you mean by "when doing the compilation"? You want to understand how the low-level instructions work to flip the bits in the register?
No, actually I want to know how we apply the operator and get the answer without using a python console!
__________________

01-22-2019, 12:05 PM   #4
Fully Optimized

Join Date: Dec 2016
Location: Argentina
Posts: 1,684
Re: Doubt regarding basic python operators!

Quote:
 Originally Posted by codeOO7 No, actually I want to know how we apply the operator and get the answer without using a python console!
All you have to do is flip the bits then. A NOT gate simply outputs the opposite of the input. If you send a 1, you'll get a 0.

If you look up a block diagram of a NOT gate you can get the idea of how it works.

Maybe you are having trouble understanding the literature because you don't know how 2's complement works. Look it up and maybe it'll be easier. Say you have 11001 -> NOT -> 00110. That's it.
__________________
"There is nothing more animal-like
than a clear conscience
on the third planet of the Sun."

01-24-2019, 04:36 AM   #5
Solid State Member

Join Date: Dec 2018
Location: India
Posts: 15
Re: Doubt regarding basic python operators!

Quote:
 Originally Posted by AMD_man All you have to do is flip the bits then. A NOT gate simply outputs the opposite of the input. If you send a 1, you'll get a 0. If you look up a block diagram of a NOT gate you can get the idea of how it works. Maybe you are having trouble understanding the literature because you don't know how 2's complement works. Look it up and maybe it'll be easier. Say you have 11001 -> NOT -> 00110. That's it.
Yeah, really I am having trouble with the 2's compliment. I also have doubt regarding the positive and negative sign of the number after using the operator!
__________________

01-24-2019, 09:01 AM   #6
Fully Optimized

Join Date: Dec 2016
Location: Argentina
Posts: 1,684
Re: Doubt regarding basic python operators!

Quote:
 Originally Posted by codeOO7 Yeah, really I am having trouble with the 2's compliment. I also have doubt regarding the positive and negative sign of the number after using the operator!
I had trouble understanding 2's complement using textbooks alone, so I used YouTube instead. There are 10 minute videos that'll make you understand the system better than any textbook.

If your textbook has exercises about it somewhere I recommend you do a couple to get acquainted.

Before learning to code you should probably have a better understanding of computers in general. The book I used (and lots of universities use) is called "Computer Science: An Overview" by Glenn Brookshear. It covers a lot of topics that anyone interested in CS should know, including binary representations, among other cool things.
__________________
"There is nothing more animal-like
than a clear conscience
on the third planet of the Sun."

01-24-2019, 10:45 AM   #7
Solid State Member

Join Date: Dec 2018
Location: India
Posts: 15
Re: Doubt regarding basic python operators!

Quote:
 Originally Posted by AMD_man I had trouble understanding 2's complement using textbooks alone, so I used YouTube instead. There are 10 minute videos that'll make you understand the system better than any textbook. If your textbook has exercises about it somewhere I recommend you do a couple to get acquainted. Before learning to code you should probably have a better understanding of computers in general. The book I used (and lots of universities use) is called "Computer Science: An Overview" by Glenn Brookshear. It covers a lot of topics that anyone interested in CS should know, including binary representations, among other cool things.
__________________

__________________