# Mixed number to rational

`mixed-number-to-rational` · version 1.0.0 · Numbers & math · free, no key needed

Convert a mixed number (sign, whole part, proper-fraction numerator and denominator) into a single reduced rational.

**Use when you need to: mixed number to rational · convert mixed number to fraction · mixed fraction to improper fraction.**

## Supported

- mixed number to rational
- convert mixed number to fraction
- mixed fraction to improper fraction

## Not supported

- rational to mixed number
- decimal conversion
- negative whole or fraction fields

## Behavior

- Input has a boolean negative field, and canonical non-negative integer-string whole and numerator fields, and a canonical positive integer-string denominator field.
- whole and numerator carry only magnitude; sign is expressed solely by the negative field, so -0 is rejected on those two fields (0 is required instead).
- numerator need not be less than denominator; an improper fraction part is accepted and combined normally.
- The value is (negative ? -1 : 1) * (whole * denominator + numerator) / denominator, reduced by gcd with sign only on the output numerator.
- A zero value (whole 0, numerator 0, any sign) always reduces to output numerator 0 over denominator 1.
- Each field and the output numerator and denominator may have at most 1000 digits excluding sign.

## Input

- `negative` (boolean, required)
- `whole` (string, required): max length 1000
- `numerator` (string, required): max length 1000
- `denominator` (string, required): max length 1001

## Output

- `numerator` (string, required)
- `denominator` (string, required)

## Limits

- max digits: 1000

## Example

Request input:

```json
{
  "negative": true,
  "whole": "3",
  "numerator": "1",
  "denominator": "2"
}
```

Response:

```json
{
  "result": {
    "numerator": "-7",
    "denominator": "2"
  }
}
```

## How to call it

### MCP

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

```json
{
  "id": "mixed-number-to-rational",
  "version": "1.0.0",
  "input": {
    "negative": true,
    "whole": "3",
    "numerator": "1",
    "denominator": "2"
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/mixed-number-to-rational/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"negative":true,"whole":"3","numerator":"1","denominator":"2"}'
```

The machine-readable contract is at [/v1/tools/mixed-number-to-rational/versions/1.0.0](/v1/tools/mixed-number-to-rational/versions/1.0.0).

### CLI

```sh
node cli.mjs run mixed-number-to-rational 1.0.0 --input input.json --base-url https://computefirst.net
```

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

## Related tools

- [Rational to mixed number](/tools/rational-to-mixed-number): Convert a rational number into a sign, whole part, and proper-fraction numerator/denominator.
- [Rational power](/tools/rational-power): Raise a rational number to an integer exponent and return the exact reduced result.
- [Rational simplify](/tools/rational-simplify): Reduce a numerator/denominator pair to lowest terms with the sign normalized onto the numerator.
- [Rational reciprocal](/tools/rational-reciprocal): Invert a rational number given as a numerator/denominator integer-string pair.
- [Angle DMS convert](/tools/angle-dms-convert): Convert a signed integer angle between degrees, arcminutes, and arcseconds as an exact rational.
- [Array integer clamp](/tools/array-integer-clamp): Clamp an array of canonical integer strings to optional inclusive min and max bounds.
