Parity Calculator - Even or Odd Across Bases

Parity calculator for any number in decimal, binary, octal, or hex. Read mathematical parity, computer-science parity, decimal value, and ones count at once.

Updated: June 19, 2026 • Free Tool

Parity Calculator

Match the base to how the number is written: decimal, binary, octal, or hexadecimal.

Type the number in the chosen base. Whitespace, a leading sign, and a base prefix (0b, 0o, 0x) are stripped before parsing.

Results

Mathematical Parity
0
Math Parity Bit 0
Computer-Science Parity 0
Ones Count 01-bits
Decimal Value 0

What Is Parity Calculator?

A parity calculator is a quick numeric tool that decides whether an integer is even or odd in any base and, for binary input, whether the count of 1-bits is even or odd. Type a number in decimal, binary, octal, or hexadecimal and read mathematical parity, computer-science parity (binary only), decimal value, and ones count in a single panel. The result relies on the same n mod 2 rule that appears in arithmetic and the simplest error-detection codes, so the tool doubles as a homework helper, a sanity check before sending a serial byte, and a teaching aid for parity conservation.

  • Even or odd checks for schoolwork: Confirm whether a homework number is even or odd in decimal without doing the long-division by 2 in your head.
  • Computer-science parity for binary messages: Count the 1-bits in a binary string and report even or odd parity, the same check a UART receiver performs on each byte.
  • Cross-base sanity check: Convert a number from binary, octal, or hexadecimal into decimal to verify that the base conversion did not lose a digit.
  • Teaching parity conservation: Demonstrate that an even number stays even and an odd number stays odd when you move between decimal, binary, octal, and hex.

Mathematical parity is the n mod 2 view of an integer: a remainder of 0 means even, a remainder of 1 means odd. Because the rule depends only on divisibility by 2, it survives any change of base that keeps the value the same.

Computer-science parity flips the focus to the count of 1-bits in the binary representation. A byte with four 1-bits has even parity, three 1-bits has odd parity, and that is exactly the single-bit parity check used in serial communication.

When you want to see the n mod 2 rule applied to a different dividend and divisor, Modulo Calculator returns the same remainder by hand.

How Parity Calculator Works

The tool strips whitespace and any 0b, 0o, or 0x prefix from the input, parses the remaining characters in the chosen base, then applies the n mod 2 rule for mathematical parity and the count of 1-bits rule for computer-science parity. The decimal value is also returned so you can confirm the base conversion was loss-free.

mathematical_parity = n mod 2; computer_science_parity = (count of 1-bits in binary n) mod 2
  • inputNumber: The integer you want to evaluate. Whitespace, a leading sign, and a base-specific prefix (0b, 0o, 0x) are stripped before parsing.
  • numberBase: The base used to interpret inputNumber: 10 for decimal, 2 for binary, 8 for octal, 16 for hexadecimal.
  • mathParity: Word result for the n mod 2 check: even or odd.
  • csParity: Word result for the count of 1-bits: even or odd (binary only, otherwise n/a).
  • onesCount: Number of 1-bits in the cleaned binary input. Reported only when base is 2.
  • decimalValue: The input converted to a base-10 integer so you can sanity-check the base parsing.

Both definitions reduce to the same modulo-2 operation, which is why every UART uses XOR across the message bus. The difference is only what gets counted: n mod 2 looks at the integer, while (count of 1-bits) mod 2 looks at the bit pattern, and the two can disagree on any given byte. Whitespace and 0b/0o/0x prefixes are stripped before parsing, so pasted dumps and C-style literals both work.

Binary 11001001 has even computer-science parity

Number = 11001001, Number Base = Binary (2)

Count the 1-bits: 1+1+0+0+1+0+0+1 = 4. 4 mod 2 = 0, so computer-science parity is even. Convert to decimal: 1*128 + 1*64 + 0 + 0 + 1*8 + 0 + 0 + 1 = 201.

Mathematical parity: odd (201 mod 2 = 1). Computer-science parity: even (4 ones). Ones count: 4. Decimal value: 201.

Notice that mathematical parity and computer-science parity disagree here: the value is odd but the count of 1-bits is even. This is exactly why serial protocols treat the count of 1-bits as a separate signal from the numeric value.

According to Wikipedia (Parity, mathematics), an integer is even if it is divisible by 2 and odd if not, and parity is conserved across any change of number base that keeps the value the same.

According to Wikipedia (Parity bit), a binary number has even parity if the count of 1-bits is even and odd parity if the count is odd; this is the XOR of every bit in the message.

When you need the same binary string turned into decimal, hex, and octal so you can verify the value by hand, Binary Converter shows the conversions side by side.

Key Concepts Explained

Four short ideas explain every value the tool returns.

Mathematical parity (n mod 2)

The remainder when the integer is divided by 2. A remainder of 0 means the number is even and a remainder of 1 means odd. The rule survives any change of base that does not alter the value, so evenness does not depend on whether you write the number in decimal or binary.

Computer-science parity

The parity of the count of 1-bits in a binary string, not the parity of the integer the bits represent. A byte with four 1-bits has even computer-science parity, a byte with three 1-bits has odd parity, and the two can disagree when the numeric value happens to be odd.

Parity conservation across bases

An even integer stays even when you rewrite it in binary, octal, or hexadecimal, and an odd integer stays odd. This is because every even base uses the last digit to encode divisibility by 2, so the rule carries through the conversion instead of being reset.

Evil and odious numbers

Mathematicians call an integer evil when its binary form has an even count of 1-bits and odious when it has an odd count. The tool reports the same evil/odious split through the computer-science parity output and the ones count.

Mathematical parity and computer-science parity are linked by XOR, so hardware implementations of either rule are equivalent under modulo-2 arithmetic. The same XOR pattern is the basis of every simple parity generator and checker.

When you want to see the XOR-of-bits version of the computer-science parity rule run on a wider register width, Bitwise Calculator shows the same bitwise operation with AND, OR, XOR, and NOT.

How to Use This Calculator

Six short steps cover every base and every input edge case.

  1. 1 Pick the base that matches your notation: decimal for everyday arithmetic, binary for bit patterns, octal for short byte groups, or hexadecimal for memory addresses.
  2. 2 Type the number in that base: Enter digits valid for the chosen base. Whitespace, a leading sign, and a 0b, 0o, or 0x prefix are stripped automatically.
  3. 3 Read mathematical parity: The primary result is the even/odd label from n mod 2. Use this for schoolwork and divisibility by 2.
  4. 4 Read computer-science parity (binary only): For binary input the panel reports the even/odd label from the count of 1-bits, plus the ones count. Use this for parity-bit work.
  5. 5 Verify with the decimal value: The Decimal Value field shows the same number in base 10. If it matches the value you started from, the base parsing was loss-free.
  6. 6 Fix invalid inputs: If the input contains a digit that is not valid for the chosen base, the panel flips to invalid and names the base. Pick a wider base or correct the digits.

You need to know whether the binary message 11001001 is ready to send over a UART line with even parity. Set Number Base to Binary, paste 11001001, and the panel reports Mathematical parity: odd (201 is odd), Computer-science parity: even (four 1-bits), Ones count: 4, Decimal value: 201. The four-ones count matches the receiver's check, so the byte is consistent with even parity at the bit-pattern level.

When you need to add or check the actual parity bit on a binary message rather than just report whether the count of 1-bits is even or odd, Even Parity Calculator generates or verifies the bit.

Benefits of Using This Calculator

Five practical reasons to keep this tool open instead of counting in your head.

  • Two parity views in one panel: Get both the mathematical parity from n mod 2 and the computer-science parity from the count of 1-bits without switching tools.
  • Four bases without manual conversion: Type a decimal, binary, octal, or hexadecimal number and read the decimal value back to confirm the base parse.
  • Forgiving input handling: Whitespace, leading signs, and 0b/0o/0x prefixes are stripped automatically, so pasted dumps and C-style literals both work.
  • Built-in ones count: The ones count field saves a separate tally when you need the count of 1-bits for a parity-bit problem or an evil/odious check.
  • Quick base-conservation check: Compare the parity label across decimal, binary, octal, and hexadecimal to confirm parity conservation without retyping the number.

Because the rule is the same modulo-2 operation everywhere, the tool doubles as a teaching aid for parity conservation and a sanity check for parity-bit problems. Anything learned in one base applies to all four.

When you want to follow the parity check with addition, subtraction, multiplication, or division in the same bit width, Binary Operations Calculator carries the binary context into the next operation.

Factors That Affect Your Results

Three inputs shape the result, and two limitations tell you when this tool is not the right choice.

Number base

Decimal, binary, octal, and hexadecimal each use a different digit set. A character that is valid in one base will be rejected in another, and the rejection message names the base that failed.

Input digits

Only the digits 0 to base - 1 are allowed. A leading sign, a 0b/0o/0x prefix, and whitespace are stripped automatically, but stray letters or punctuation trigger an invalid-input error.

Negative values

A leading minus sign keeps the sign of the value but the parity is taken from the magnitude, matching the standard convention that -7 and 7 share the same parity.

  • Mathematical parity is defined for integers. Non-integer inputs (decimals, fractions, scientific notation) are not supported and trigger an invalid-input error.
  • Single-bit parity catches any odd number of bit flips but not an even number, because two flips cancel. If the channel can flip two bits at once, you need a CRC or hash on top of parity.

The binary parser does not enforce a maximum bit width, so very long binary strings run without complaining. The practical limit is the JavaScript number range, which keeps parity exact up to about 2^53 before the conversion starts to lose precision.

According to MathWorld (Parity), an integer is even when its last binary digit is 0 and odd when it is 1, and this rule extends unchanged to every even base because the parity of n is determined entirely by n mod 2.

For the negative-value factor specifically, Twos Complement Calculator shows the bit pattern that the parity check is reading on a negative integer, so you can verify the sign extension by hand before trusting the parity label.

Parity calculator interface showing number base selector, decimal, binary, octal, and hexadecimal input with mathematical and computer-science parity output.
Parity calculator interface showing number base selector, decimal, binary, octal, and hexadecimal input with mathematical and computer-science parity output.

Frequently Asked Questions

Q: Is zero an even number?

A: Yes, zero is even. According to the standard definition, an integer is even when it is divisible by 2 with no remainder, and 0 mod 2 is 0. The tool returns even for an input of 0 in any base.

Q: How do you find the parity of a number?

A: Take the number and divide it by 2. If the remainder is 0 the number is even, and if the remainder is 1 the number is odd. The tool runs the same n mod 2 rule and returns even or odd along with the remainder bit.

Q: What is the parity of a binary message?

A: Count the 1-bits in the binary string. If the count is even the message has even parity, and if the count is odd the message has odd parity. This is the computer-science parity used in serial protocols and is what a single-bit parity checker recomputes on the receiver side.

Q: Is parity the same in different number bases?

A: Yes, parity is conserved across any change of base that does not alter the value. An even integer stays even when you rewrite it in binary, octal, or hexadecimal, and the same holds for odd integers. The tool keeps the label consistent across all four supported bases.

Q: What is the parity of 11001001?

A: The message 11001001 has even computer-science parity because it contains four 1-bits, and 4 mod 2 is 0. The numeric value is 201, which is odd, so mathematical parity and computer-science parity disagree on this byte. The tool reports both labels side by side.

Q: How is parity used in computer science?

A: Parity is the simplest form of error detection. A sender adds a parity bit so the count of 1-bits in the transmitted byte is even (or odd, depending on the protocol), and the receiver recomputes the same count to spot single-bit flips. The same rule is what this tool reports as computer-science parity.