Integer parity checker
Count the ones in a number's binary form and get its parity: 13 is 1101, with three ones, so its parity is odd and the parity bit is 1. You also see the binary string and how many ones and zeros it holds. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- N
- 13
- Magnitude
- 13
- Binary
- 1101
- Bit length
- 4
- Ones count
- 3
Integer parity—whether the binary representation of a number contains an even or odd count of one-bits—is a foundational check in coding theory, checksum design, and low-level debugging. Students learning popcount, engineers verifying bit-packing layouts, and automation scripts that need a deterministic even-or-odd ones answer all benefit from a single contract that never invents bits from floating noise.
What integer set-bit parity means and how popcount defines it
The set-bit parity of an integer is the parity of its population count: write the magnitude in base two, count how many digits are one, and reduce that count modulo two. When the ones count is even the integer has even parity and the parity bit is zero; when the ones count is odd the integer has odd parity and the parity bit is one.
This is the same structural idea that underlies simple parity checks in communication systems, the least-significant bit of a Hamming weight, and classroom exercises that ask whether a number is even-parity or odd-parity in binary—not whether the number itself is even or odd as a decimal quantity. Zero is binary 0 with zero ones, which is even parity. The algorithm is a short loop of shifts and masks—or any equivalent popcount—so the answer is unique, side-effect free, and identical across every runtime that implements safe integers the same way.
No network call, random seed, or wall-clock time participates in the result.
What you can do with it
Coding and error-detection demos
Sample ones-parity for packed integer fields when teaching simple parity checks before CRC or Hamming in lab notebooks.
LMS and interview auto-grading
Mark popcount-parity items with a deterministic oracle that rejects non-integers and never invents bits from floating or unsafe values.
FAQ
How does the integer parity checker decide even vs odd?
It counts the one-bits in the binary form of |n| (popcount) and reduces modulo 2.
What happens with negative integers?
The original signed n is echoed, but bit work uses the absolute value (magnitude). No two's-complement width is assumed.
Is this the same as asking whether n is an even number?
No. Decimal even/odd looks only at divisibility by two. Set-bit parity looks at how many 1-bits appear in the binary expansion. Example: 2 is an even number but binary 10 has one set bit (odd parity).
How is this different from a parity-bit calculator or Thue-Morse bit?
A parity-bit tool appends or verifies a parity bit on an arbitrary bit string or byte. Thue-Morse names the sequence t(n)=popcount(n) mod 2 for non-negative indices. This checker targets integer set-bit parity for general coding and error-detection checks, including signed magnitude handling and diagnostic fields.
What is the parity of zero?
Even. Zero is 0 in binary and has no one-bits, and a count of zero ones is even, so the parity bit is 0. The same rule gives even parity for 10, which is 1010 with two ones.
Related tools
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/dev/integer-parity \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"n":13}'const res = await fetch("https://api.kit.forhosting.com/dev/integer-parity", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"n": 13
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/dev/integer-parity",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"n": 13
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/dev/integer-parity", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"n":13}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"n":13}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/dev/integer-parity", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"n": 13
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "dev.integer_parity",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |
Technical notes
This integer parity checker accepts an integer n, works on its absolute value so signed classroom inputs stay well-defined without picking an arbitrary two's-complement width, returns the binary string, the ones and zeros counts, the parity label (even or odd), and the parity bit zero or one, and rejects non-integers with invalid_input so graders and pipelines never treat a fractional payload as a success.
What integer set-bit parity means and how popcount defines it
For example, thirteen is binary 1101 with three ones, so ones_count is three, parity is odd, and parity_bit is one. Ten is binary 1010 with two ones, so parity is even and parity_bit is zero. Negative inputs are accepted for convenience, but the bit expansion always uses the absolute value: negative thirteen shares the same ones count and parity as thirteen, and the response echoes the original signed n next to magnitude so clients can display both. That absolute-value rule avoids inventing a machine word width for two's complement, which would make the same mathematical integer report different parities at thirty-two versus sixty-four bits.
Input contract, response fields, and error behaviour
POST a JSON body with a single required field n: an integer, either as a JSON number or as a decimal digit string that fits the JavaScript safe-integer range (including a leading plus or minus). Aliases value, number, integer, and x are accepted when n is omitted so form widgets and quick scripts can use familiar labels. Missing n, empty strings, non-integers, non-finite numbers, and values outside the safe integer range fail with invalid_input naming the problem; those validation failures are not billed. On success the body echoes n, provides magnitude as the absolute value used for bit work, binary as the base-two string of that magnitude without a 0b prefix (zero yields the single character 0), bit_length as the length of that string, ones_count as the number of one-bits, zeros_count as the number of zero-bits in the same expansion, parity as the string even or odd, parity_bit as 0 or 1, is_even_parity as a boolean mirror of even parity, and a short formula string restating that parity equals popcount of absolute n modulo two. Example: n equals thirteen yields magnitude thirteen, binary 1101, bit_length four, ones_count three, zeros_count one, parity odd, parity_bit one, and is_even_parity false. Example: n equals zero yields binary 0, ones_count zero, parity even, and parity_bit zero. Clients that only need a boolean can read is_even_parity; tutors can show binary and ones_count next to the answer so students audit the count.
Where an integer parity checker earns its keep
Firmware and protocol notebooks often need a quick oracle for whether a packed field has even or odd ones while designing simple parity schemes or verifying hand-computed truth tables. Pair this checker with a separate parity-bit append tool when you need to attach a parity bit to an arbitrary bit string; this capability focuses on the integer itself and its ones count, which is the search intent behind an integer parity checker rather than a Thue-Morse sequence index or a free-form bit-string encoder. Coding-theory and digital-design courses use set-bit parity when introducing error-detection ideas before full CRC or Hamming codes; a tiny API lets LMS plugins check student answers for arbitrary integers without shipping a full bit-twiddling library. Debugging tools and interview-prep generators can call this endpoint to produce deterministic even/odd labels with intermediate binary diagnostics instead of pasting ad-hoc JavaScript that diverges on zero, on negatives, or on large safe integers. Because every successful call costs the published $0.002 base price with no model tokens and no outbound network, failed validation does not consume balance, and the algorithm is a handful of bit operations, you get reproducible parity answers for homework, grading, checksum demos, and edge workers without standing up heavier encoding infrastructure. Keep requests small, document that n is a safe integer and that magnitude drives the bits, and treat parity and parity_bit as the canonical answer fields for automated checks.
Integration use cases
Classroom and homework checks
Let students submit an integer n and verify even/odd set-bit parity against popcount, with binary and ones_count shown for partial credit.
Technical questions
What does the integer parity checker cost?
The browser tool is free. API requests use prepaid KIT balance at $0.002 per successful call; invalid input is not billed.