# Integer bitwise compute

`integer-bitwise-compute` · version 1.0.0 · Numbers & math · free, no key needed

Compute fixed-width integer AND, OR, XOR, NOT, AND-NOT, shifts or rotates; returns decimal, hex and binary.

**Use when you need to: bitwise AND OR shift integer · integer bitwise mask flags hexadecimal bit operations · bitwise integer and or xor left shift 16 bit mask.**

## Decide before calling

Read the [versioned contract](/v1/tools/integer-bitwise-compute/versions/1.0.0) and the supported scope below. Reuse `integer-bitwise-compute@1.0.0` when your input, required output and limits match it. Choose another approach for an unsupported operation.

## Explain the choice

"I can use `integer-bitwise-compute@1.0.0` for bitwise AND OR shift integer. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."

## Supported

- bitwise AND OR shift integer
- integer bitwise mask flags hexadecimal bit operations
- bitwise integer and or xor left shift 16 bit mask
- unsigned integer bitwise and shift bit flags
- rotate fixed width integer bits
- arithmetic right shift signed integer
- AND-NOT clear integer mask

## Not supported

- floating-point bit operations
- variable or unbounded bit widths
- byte-string XOR

## Behavior

- Integer values are safe JSON integers or strings matching -?(0|[1-9][0-9]*|0[xX][0-9a-fA-F]+|0[bB][01]+|0[oO][0-7]+); no whitespace, plus sign, separators, or leading decimal zeroes.
- All operations use the explicit width and two's-complement bit pattern; results are fixed-width lowercase hex and binary plus signed or unsigned decimal.
- Shift/rotate count is 0 through width-1. Logical right shift inserts zeroes; arithmetic right shift replicates the sign bit.

## Input

- `operation` (one of "and", "or", "xor", "not", "and_not", "shift_left", "shift_right_logical", "shift_right_arithmetic", "rotate_left", "rotate_right", required)
- `width` (one of 8, 16, 32, 64, 128, required)
- `signed` (boolean, required)
- `a` (string or integer, required)
- `b` (string or integer, optional)
- `count` (integer, optional): min 0; max 127

## Output

- `standard_version` (string, required)
- `width` (integer, required)
- `signed` (boolean, required)
- `decimal` (string, required)
- `hex` (string, required)
- `binary` (string, required)

## Limits

- max input bytes: 256
- max output bytes: 1024
- max width bits: 128
- max iterations: 128

## Example

Request input:

```json
{
  "operation": "and",
  "width": 8,
  "signed": false,
  "a": "0xf3",
  "b": "0x5a"
}
```

Response:

```json
{
  "result": {
    "standard_version": "ISO/IEC 9899:2018 6.5.7, 6.5.10-6.5.12; ISO/IEC 14882:2020 [basic.fundamental]",
    "width": 8,
    "signed": false,
    "decimal": "82",
    "hex": "0x52",
    "binary": "0b01010010"
  }
}
```

## How to call it

### MCP

Connect `https://computefirst.net/mcp` ([setup](/docs#connect)), then call `execute` with:

```json
{
  "id": "integer-bitwise-compute",
  "version": "1.0.0",
  "input": {
    "operation": "and",
    "width": 8,
    "signed": false,
    "a": "0xf3",
    "b": "0x5a"
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/integer-bitwise-compute/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"operation":"and","width":8,"signed":false,"a":"0xf3","b":"0x5a"}'
```

The machine-readable contract is at [/v1/tools/integer-bitwise-compute/versions/1.0.0](/v1/tools/integer-bitwise-compute/versions/1.0.0).

### CLI

```sh
node cli.mjs run integer-bitwise-compute 1.0.0 --input input.json --base-url https://computefirst.net
```

Get the client at [/clients/cli/](/clients/cli/).

## Related tools

- [Integer expression evaluate](/tools/integer-expression-evaluate): Evaluate exact integer arithmetic and return decimal, hexadecimal, and binary results.
- [Integer bits inspect](/tools/integer-bits-inspect): Inspect or edit fixed-width integer bits and fields; returns set positions, popcount and decimal, hex and binary.
- [Integer twos complement convert](/tools/integer-twos-complement-convert): Reinterpret one fixed-width two's-complement pattern as signed and unsigned; returns both decimals, hex and binary.
- [Integer expression parse](/tools/integer-expression-parse): Parse an integer expression and return its tokens, required variables, precedence tree, and precedence table.
- [Idna bidi check](/tools/idna-bidi-check): Apply the RFC 5893 Bidi Rule to one label and name the first failing condition.
- [Idna context check](/tools/idna-context-check): Report every IDNA2008 CONTEXTJ and CONTEXTO finding in one mapped label.
