Skip to content

Main content

Integer Negabinary Digit Parity Tool

Count the ones and digit length in the canonical base −2 expansion, including one zero digit for zero.

Loading tool…

Description

Count the ones and digit length in the canonical base −2 expansion, including one zero digit for zero.

A positional representation depends on its radix, digit range, sign convention, and treatment of leading zeros. Ordinary bases use digits from zero through radix minus one, while negative and bijective bases have different conversion rules. A single carry, borrow, or denominator step is distinct from formatting a complete number.

Count the ones and digit length in the canonical base −2 expansion, including one zero digit for zero.

When to use this tool

Use Integer Negabinary Digit Parity when you need this digit, carry, borrow, sign, width, or denominator component for an explicit radix convention.

How to use the tool and how it works

  1. Enter integer. Use the units and conventions below.
  2. Run the tool. Correct any format, range, or cross-field input error before interpreting the output.
  3. Read digitCount, ones, parity. Use the output convention below.

Parse a signed decimal integer and repeatedly divide by -2, adjusting a negative remainder into zero or one and increasing the quotient. Count digits and one bits, returning digitCount, ones, and parity=ones modulo two.1

Input fieldMeaning and unitsAccepted input
integerSafe integer number or exact signed decimal-integer text as declared below.Required. Text; maximum UTF-16 length 8192. Integer syntax: optional + or - and 1-128 decimal digits; leading zeros accepted. Apply the sign restriction above.
Output fieldInterpretationReturned shape
digitCountDigit CountRequired. Safe integer.
onesOnesRequired. Safe integer.
parityOne-bit population-count parity of the negabinary digits, not numeric odd/even.Required. Safe integer.
json
{
  "input": {
    "integer": "-3"
  },
  "output": {
    "digitCount": 4,
    "ones": 3,
    "parity": 1
  }
}

Limitations and assumptions

  • This uses the canonical negabinary expansion without leading zeros. Input zero still has one zero digit; parity describes the population count rather than the input integer's arithmetic parity.
  • Inputs must satisfy both the field types and the cross-field conditions above. Invalid input causes an error; a successful false flag or documented placeholder is a different result.

Alternative or Complementary methods

Choose the full conversion or formatting workflow for the intended representation. Keep radix, digit alphabet, leading-zero width, signed-zero handling, and terminating/repeating-fraction assumptions explicit.

References

  1. Calculation and input contract: number/integer-negabinary-digit-parity — tool.io

Similar or alternative tools