Bitwise Calculator

Bitwise operations work directly on the binary representation of integers, testing or modifying individual bits rather than treating a number as a whole. They appear throughout low-level programming: setting and clearing flags in microcontroller registers, packing multiple boolean values into a single byte, writing encryption and hashing routines, implementing fast modulo operations for powers of two, and checking parity in communications protocols. The four fundamental operations are AND, OR, XOR and NOT. AND produces a 1 only where both inputs have a 1 in that bit position; it is the standard way to isolate or test a bit. OR produces a 1 wherever either input has a 1; it sets bits. XOR produces a 1 only where the two inputs differ; it is used to toggle bits or detect differences. NOT flips every bit of its single operand, turning 0s into 1s and vice versa, which in two's complement arithmetic gives the negative minus one of the input. This calculator takes two decimal integers, A and B, and returns the result of all four operations at once, showing both the decimal value and the binary bit pattern so you can see exactly which bits changed. The NOT result shown applies to A only. Enter any two integers, positive or negative, and the results update immediately.

Calculate.co.nz is proud to be partnered with Health Based Building, a leader in sustainable and health-conscious building innovation. With over a century of experience, they develop high-performance systems like Foreverbreathe Specification, Magnum Board, and Foreverbreathe Paints to support energy-efficient, non-toxic living environments. Their commitment to healthier homes aligns with our belief that informed choices lead to better outcomes for Kiwi households.
Calculate.co.nz partner: Health Based Building
12
A AND B (decimal)
A AND B binary00001100
A OR B61
A OR B binary00111101
A XOR B49
A XOR B binary00110001
NOT A-61
A binary00111100
B binary00001101

How it works

Each input is parsed as a signed decimal integer. JavaScript performs bitwise operations on 32-bit signed integers internally, so very large numbers are truncated to 32 bits. AND (&) is applied bit by bit: only positions where both A and B have a 1 produce a 1 in the result. OR (|) sets any bit that is 1 in either operand. XOR (^) sets bits that differ between the two operands. NOT (~) inverts all bits of A, which in two's complement gives -(A+1). Binary representations are padded to at least 8 bits for readability. Negative results display in standard signed notation.

Worked example

A = 60 in binary is 00111100. B = 13 in binary is 00001101. AND: only positions 3 and 2 (from the right, 0-indexed) are 1 in both, giving 00001100 = 12. OR: any bit that is 1 in either gives 00111101 = 61. XOR: bits that differ give 00110001 = 49. NOT A: flipping all bits of 60 gives -61. These match the defaults already in the calculator above.

Related calculators

If you've found a bug, or would like to contact us, or learn more about James Graham and Calculate.co.nz.

Calculate.co.nz is partnered with Interest.co.nz for New Zealand's highest quality calculators and financial analysis.

All calculators and tools are provided for educational and indicative purposes only and do not constitute financial advice.

Calculate.co.nz is proudly part of the Realtor.co.nz group, New Zealand's leading property transaction literacy platform, helping Kiwis understand the home buying and selling process from start to finish. Whether you're a first home buyer navigating your first property purchase, an investor evaluating your next acquisition, or a homeowner planning to sell, Realtor.co.nz provides clear, independent, and trustworthy guidance on every step of the New Zealand property transaction journey.

Calculate.co.nz is also partnered with Health Based Building and Premium Homes to promote informed choices that lead to better long-term outcomes for Kiwi households.

Calculate.co.nz is hosted in Auckland via SiteHost new Zealand.

All content on this website, including calculators, tools, source code, and design, is protected under the Copyright Act 1994 (New Zealand). No part of this site may be reproduced, copied, distributed, stored, or used in any form without prior written permission from the owner.

About & trust: Why Calculate is NZ's most comprehensive · By the Numbers · How we compare · Editorial standards · How we keep data current · NZ finance glossary · Research & data · Financial literacy NZ · About · Privacy policy · Terms of use

Reviewed and maintained. Last reviewed 2026-06-25 and checked on a twice-monthly cycle against IRD, RBNZ and Stats NZ. How we keep data current.

© 2026 Calculate.co.nz. All rights reserved. Building free NZ calculators since 2011.