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 1000numerator(string, required): max length 1000denominator(string, required): max length 1001
Output
numerator(string, required)denominator(string, required)
Limits
- max digits: 1000
Example
Request input:
{
"negative": true,
"whole": "3",
"numerator": "1",
"denominator": "2"
}
Response:
{
"result": {
"numerator": "-7",
"denominator": "2"
}
}
How to call it
MCP
Connect https://computefirst.net/mcp (setup), then call execute with:
{
"id": "mixed-number-to-rational",
"version": "1.0.0",
"input": {
"negative": true,
"whole": "3",
"numerator": "1",
"denominator": "2"
}
}
HTTP (no key)
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.
CLI
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/.
Related tools
- Rational to mixed number: Convert a rational number into a sign, whole part, and proper-fraction numerator/denominator.
- Rational power: Raise a rational number to an integer exponent and return the exact reduced result.
- Rational simplify: Reduce a numerator/denominator pair to lowest terms with the sign normalized onto the numerator.
- Rational reciprocal: Invert a rational number given as a numerator/denominator integer-string pair.
- Angle DMS convert: Convert a signed integer angle between degrees, arcminutes, and arcseconds as an exact rational.
- Array integer clamp: Clamp an array of canonical integer strings to optional inclusive min and max bounds.