Skip to main content

BITWISE NOT

Bitwise NOT

The NOT bitwise operation inverts bits. A 0 becomes a 1. A 1 becomes a 0.

The NOT operator is often written as a tilde character ("~"):

  ~ 0000 0101
= 1111 1010

When numbers are printed in base-10, the result of a NOT operation can be surprising. In particular, positive numbers can become negative and negative numbers can become positive. For example:

  ~ 5  // gives -6

// At the bit level:
//   ~ 0000 0101  (5)
//   = 1111 1010  (-6)

This is because numbers are (usually) represented using two's complement, where the leftmost bit is actually negative. So flipping the leftmost bit usually flips the sign of the number.

Comments

Popular posts from this blog

A simple calculator for adding and subtracting in c++

A simple calculator for adding and subtracting in c++ In this post, I write a code about very simple calculator in c++. Actually it is the problem in e-olymp.com If you're not familiar with this website then you can go below link: https://www.e-olymp.com/en/problems/7411 Input is in this form :                                               x+5=2  or 1+x=4  or  1+4=x In the output we give the value of x. It has very simple solution. That's why i give there only code and when you read this code line-by-line you easily understand it     :) Solution: #include <iostream> #include <string> using namespace std ; int main (){ string statement ; cin >> statement ; int last_number = 0 ; if (statement [ statement.length()- 1 ] == '0' || statement [ statement.length()- 1 ] == '1' || statement [ statement.length()- 1 ] == '2' || statement [ s

SQL - Part 1

                                            SQL tutorial from scratch -- Part 1                                                             Introduction Before going deep dive into in SQL I want to explain the main purpose of DB(database). Suppose we have large amount of data (for example it would be the students in the same class), and we want to create some website which is give us all information about them. How we do it. Of course using database.Maybe you ask yourself questions: "I can store them in file or array". Yes you is exactly right. But imagine you have large amount of data and if you store them in file or array your program/website will work very hard. Now let's visualize databases: As we can see it is one of the basic db type which is store title, release_year, length and replacement_cost. Don't worry about DB if you don't understand them very well. Our next paragraphs will explain it more accurately and also I try to add some impor

Representing Graphs in C++

                           How to represent graphs in C++ Todays one of the most important topic is Graph theory. Maybe someone of you wouldn't be familiar with it, is yes then go to  http://mypdf.pythonanywhere.com/  there go to programming books and there you can find Kenneth Rosen Discrete Mathematics books just download it and 10, 11th paragraphs about graphs. You must read for understanding today's lesson. Sometimes in my website cause some errors (it is developing) if yes then contact me  my_email  and I will send you the book. Now let's speak about graphs: Graphs are used everywhere:  in websites, in social media apps (such a Facebook), telephone calls and so on. If in future you want to write great applications you must know about graphs and also implement them. The basic terms of graphs are vertices(plural) and vertex(single), degree of graph deg(G), neighborhood of graphs (adjacency of graphs), simple graphs, loops and so on. For better unde