|

Bitwise Calculator Online Free

Bitwise Calculator

Work out AND, OR, XOR and NOT on whole numbers, with each answer shown in decimal and in binary — free, in your browser, nothing uploaded.

NOT uses only the first number. The other three operations use both numbers.

Note: NOT uses 32-bit two’s complement, so NOT 12 = -13. In binary, -13 is shown as its 32-bit two’s complement form.

If you have ever searched for an xor calculator, you probably had a very practical question: what happens when two numbers are combined bit by bit? A bitwise calculator answers that question in seconds. Enter two whole numbers, choose AND, OR, XOR, or NOT, and you get the result in ordinary decimal numbers and in binary, the language of ones and zeros that computers actually use. This page explains what bitwise operations are, how to use the free bitwise calculator on Your Smart Kit, and where these operations turn up in everyday technology, from the settings on your phone to the colours on your screen.

The tool itself sits at the top of the page. The rest of this article is here to help you understand the answers it gives, check them by hand, and use them with confidence, whether you are a student learning binary for the first time, a programmer checking a mask, or simply someone curious about how computers compare numbers at the lowest level.

What Are Bits and Bitwise Operations?

A bit is the smallest piece of information a computer can store: a single 0 or 1. Everything a computer does, from displaying a photo to playing a song, is ultimately built from long strings of bits. A group of bits forms a binary number. In binary, each position is worth twice as much as the position to its right, just as each position in decimal is worth ten times as much as the position to its right. So the decimal number 12 is 1100 in binary, because 8 plus 4 equals 12, and the decimal number 10 is 1010 in binary, because 8 plus 2 equals 10. Writing the two numbers one above the other, lined up by position, makes bitwise operations easy to see:

  12 = 1100
  10 = 1010

A bitwise operation compares the two numbers column by column, one bit at a time, and builds a new binary number from the results. It does not add the numbers, multiply them, or treat them as quantities in the usual sense. It treats each number as a row of switches, each switch either off (0) or on (1), and combines the switches in pairs. That is why the word “bitwise” matters: the operation works bit by bit, not on the whole number at once.

There are four basic bitwise operations in this bitwise calculator, and each one follows a simple rule for a pair of bits.

AND gives 1 only when both bits are 1. If either bit is 0, the result is 0. Think of it as “both must be on”. OR gives 1 when at least one bit is 1. It gives 0 only when both bits are 0. Think of it as “at least one must be on”. XOR, short for “exclusive or”, gives 1 only when the two bits are different: one is 1 and the other is 0. When both bits are the same, whether both 0 or both 1, XOR gives 0. Think of it as “exactly one must be on”. NOT is different from the other three because it works on a single number rather than a pair. It flips every bit: each 1 becomes 0, and each 0 becomes 1. That flipping is why NOT can produce a surprising-looking answer, which this article explains honestly in the limits section below.

Using the example above, 12 AND 10, 12 OR 10, and 12 XOR 10 can all be worked out by lining up 1100 and 1010 and applying the rule in each column. The calculator does exactly this, instantly, and shows the answer in both decimal and binary so you can check the working for yourself.

How to Use the Bitwise Calculator

Using this xor calculator and bitwise calculator is deliberately simple. Enter a whole number in the first box and a whole number in the second box, then press the button for the operation you want: AND, OR, or XOR. The answer appears below the buttons in decimal, followed by its binary form in brackets. For example, pressing XOR with 12 and 10 in the boxes gives 6, with the binary form 110.

To use NOT, you only need the first box. Enter a number there and press “NOT (first number)”. The second box is ignored for NOT, so you can leave it empty. The result is shown in the same way, in decimal and in binary.

If you leave a box empty, or type something that is not a whole number, such as 12.5 or a letter, the tool does not crash or give a misleading answer. It shows a clear message asking you to enter a whole number, and you can correct the input and try again. This matters because bitwise operations only make sense on whole numbers. A fraction has no clean bit pattern in this context, so the honest behaviour is to ask for a whole number rather than to guess.

You can run as many calculations as you like, one after another. Change either number, press a different operation button, and the new answer appears alongside the previous ones, so you can compare AND, OR, and XOR on the same pair of numbers without retyping them. That comparison is often the most instructive part: the same two numbers can give three quite different answers, and seeing them side by side makes the difference between the three rules concrete.

Worked Examples

Start with the pair used throughout this article: 12 and 10. In binary, 12 is 1100 and 10 is 1010. Line them up and work column by column, from left to right.

For AND, a column gives 1 only when both bits are 1. The columns are 1 and 1, which gives 1; 1 and 0, which gives 0; 0 and 1, which gives 0; and 0 and 0, which gives 0. The result is 1000 in binary, which is 8 in decimal. So 12 AND 10 = 8. This is the first live test for the tool, and it is the answer you should see when you press AND with 12 and 10 entered.

For OR, a column gives 1 when at least one bit is 1. The columns give 1, 1, 1, and 0, so the result is 1110 in binary, which is 14 in decimal. So 12 OR 10 = 14. This is the second live test, and it shows why OR usually gives a larger answer than AND on the same pair: OR keeps a 1 whenever either number has one, while AND keeps a 1 only where both numbers agree on 1.

For XOR, a column gives 1 only when the bits differ. The columns are 1 and 1, which are the same, so 0; 1 and 0, which differ, so 1; 0 and 1, which differ, so 1; and 0 and 0, which are the same, so 0. The result is 0110 in binary, which is 6 in decimal, normally written simply as 110. So 12 XOR 10 = 6. This is the third live test, and it is the calculation most people come to an xor calculator for. Notice that XOR highlights exactly where the two numbers differ and cancels out exactly where they agree. That property is what makes XOR useful in real code, as the next section explains.

A further example helps to show NOT. NOT 12 flips every bit of 12. In 32-bit form, 12 is a long row of zeros ending in 1100, and flipping every bit gives a long row of ones ending in 0011, which, under the two’s complement system explained below, is the number -13. So NOT 12 = -13. If that looks strange at first, you are not alone: it surprises almost everyone the first time they see it. The tool states this plainly rather than hiding it, because an honest calculator should not pretend that NOT behaves like ordinary arithmetic negation. NOT 12 is not -12. It is -13, for a precise reason that the limits section sets out.

Another quick pair is worth trying: 5 and 3. In binary, 5 is 101 and 3 is 011. AND gives 001, which is 1, because only the last column has 1 in both numbers. OR gives 111, which is 7. XOR gives 110, which is 6. Trying a few pairs like this, and checking one column at a time, is the fastest way to build a feel for all three operations.

Where Bitwise Operations Are Used

Bitwise operations sound abstract, but they are quietly at work in technology you use every day. The plain-English explanations below avoid jargon wherever possible, and explain any technical term the first time it appears.

One of the most common uses is flags. A flag is a single on-or-off setting stored inside a larger number. Imagine a user account with several permissions, meaning things that user is allowed to do, such as read a file, write to a file, or delete a file. Instead of storing each permission as a separate yes-or-no record, a program can store them as separate bits inside one number: one bit for reading, one for writing, one for deleting, and so on. AND can then test whether a particular permission is switched on, OR can switch a permission on without disturbing the others, and XOR can toggle a permission, switching it from on to off or from off to on. The word “mask” is often used for a number whose bits pick out the settings you care about, in the same way a stencil mask picks out the parts of a surface you want to paint. A mask combined with AND reveals only the bits the mask selects and hides the rest.

Permissions on files and in operating systems work in a similar way. When a system says a file can be read but not changed, that distinction is often stored as bits and checked with AND. Network settings also rely on bitwise operations: a network mask, a number that separates the part of an address identifying the network from the part identifying a single device, is applied with AND to work out which network a device belongs to. If you have ever configured a home router, a mask was working behind the scenes, even though you never saw the binary.

Graphics and colour are another everyday use. A colour on a screen is commonly stored as a single number packing together its red, green, and blue components. Bitwise operations can pull one component out of that packed number, combine components into a new colour, or make a colour transparent by blending bits. Game graphics, image filters, and photo editors all use these tricks thousands of times a second, because working bit by bit is fast. Speed is, in fact, one of the main reasons programmers reach for bitwise operations at all: a computer’s processor can perform them in a single step, which makes them useful in embedded code, the small programs that run inside devices such as washing machines, remote controls, car sensors, and medical monitors, where processing power and battery are limited and every step counts.

XOR has one more famous use: it can hide and reveal information. If you combine a message with a secret key using XOR, the result looks scrambled. Combine the scrambled result with the same key again using XOR, and the original message comes back, because XOR cancels itself out in exactly the way the worked example showed: bits that agree become 0, and applying the same difference a second time restores the original. This is the basic idea behind some simple encryption, the process of scrambling information so that only someone with the key can read it, and behind error checking, where XOR is used to spot whether data has changed during transmission. None of this requires you to write code to appreciate it: the same “spot the difference, then cancel it out” behaviour is what you saw when 12 XOR 10 gave 6.

Limits: 32-Bit Integers and the NOT Result

An honest tool states its limits, and this bitwise calculator has two worth knowing. First, it works with 32-bit integers. That means each number is treated as a row of 32 bits, which covers whole numbers from -2,147,483,648 to 2,147,483,647. Numbers outside that range are not accepted, and the tool asks for a number inside the range instead. For everyday learning, checking a mask, or testing a small example, this range is far more than enough. If you need larger numbers, a specialist programming tool is the right next step, but the rules of AND, OR, and XOR are exactly the same at any size: only the length of the row of bits changes.

Second, the NOT result needs a careful explanation, because it is the one answer that can look wrong when it is in fact correct. Computers store negative numbers using a system called two’s complement. In plain terms, two’s complement is an agreed way of reading a row of bits so that the same row can represent either a large positive number or a negative number, with the leftmost bit acting as a sign indicator. Under this system, flipping every bit of a number and then adding one gives its negative. Flipping every bit on its own, which is what NOT does, therefore gives one less than the negative: NOT 12 is -13, NOT 0 is -1, and NOT -1 is 0. The tool shows the binary result for a negative answer in its full 32-bit two’s complement form, so you can see the flipped bits for yourself. This is standard behaviour in every mainstream programming language, not a quirk of this calculator, and knowing it saves real confusion when you first meet NOT in code.

The calculator also only accepts whole numbers, for the reason given earlier: fractions do not have a single natural bit pattern in this setting. If you enter a decimal such as 12.5, the tool asks for a whole number rather than silently rounding it and giving an answer you did not ask for.

Privacy: Everything Runs in Your Browser

Every number you enter into this bitwise calculator stays in your browser. Nothing is uploaded to a server, nothing is stored, and there is no account to create. The calculation happens on your own device, using only the numbers you typed. That is a sensible default for a tool like this: the numbers might be part of homework, part of a work project, or part of a security experiment, and none of that needs to leave your computer. Closing the page removes your inputs, and you can use the tool again any time, free, without signing up.

Frequently Asked Questions

What is an xor calculator?

An xor calculator is a tool that computes XOR, the “exclusive or” operation, on two numbers. XOR compares the numbers bit by bit and gives 1 only where the bits differ. For example, 12 XOR 10 = 6, because 12 is 1100 in binary, 10 is 1010, and the bits differ in exactly the positions that make up 6, which is 110. This page includes a full xor calculator alongside AND, OR, and NOT, so you can compare all four operations on the same pair of numbers.

What is the difference between AND, OR, and XOR?

AND gives 1 only when both bits are 1. OR gives 1 when at least one bit is 1. XOR gives 1 only when the bits are different. On 12 and 10, AND gives 8, OR gives 14, and XOR gives 6. The difference is easiest to remember as: AND means both, OR means at least one, XOR means exactly one.

Why does NOT 12 equal -13 instead of -12?

Because computers store negative numbers in two’s complement, as explained in the limits section. Flipping every bit of 12 and reading the result as a signed 32-bit number gives -13. In general, NOT a number equals that number negated, minus one. So NOT 0 is -1, NOT 5 is -6, and NOT -1 is 0. The calculator states this in the tool itself, so the answer never comes as an unexplained surprise.

Can I use this bitwise calculator with negative numbers?

Yes, as long as the number is a whole number within the 32-bit range from -2,147,483,648 to 2,147,483,647. Negative inputs are read in two’s complement form, exactly as a programming language would read them, so the results match what you would get in code.

What happens if I enter a decimal or leave a box empty?

The tool shows a clear message asking for a whole number, and no result is shown. It does not crash, round your input silently, or guess. Correct the input and press the button again.

Are my numbers stored or shared?

No. The calculation runs entirely in your browser. Your numbers are never uploaded, stored, or shared with anyone, and closing the page clears them.

What are flags and masks in simple terms?

A flag is a single on-or-off setting, and a mask is a number used to select or test particular flags. For example, if one bit in a number means “can edit” and another means “can delete”, a mask lets a program check or change one permission without affecting the others. Programmers use AND, OR, and XOR with masks to test, switch on, switch off, and toggle flags efficiently.

Related Tools on Your Smart Kit

If you found this bitwise calculator useful, you may also like the other calculators on Your Smart Kit, including the date calculator for working out days between dates and the unit converter for converting between measurement units. Each runs in your browser, free, with no sign-up, and each is built on the same principle: a simple tool that does one job well, keeps your data private, and gives an answer you can check. Try the bitwise calculator at the top of this page with 12 and 10, compare AND, OR, and XOR side by side, and bookmark it for the next time a binary question comes up.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *