Compare fractions
Find out which of two fractions is larger, exactly: 3/4 beats 2/3, and 1/2 and 2/4 come out equal because they are the same value. The verdict uses whole-number cross-multiplication, so rounding never flips it. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Numerator 1
- 3
- Denominator 1
- 4
- Numerator 2
- 2
- Denominator 2
- 3
- Comparison
- 1
- Larger
- first
The comparison is done with exact integer cross-multiplication, not with floating-point division, so the answer is correct even for huge numerators and denominators where decimal rounding would silently flip the result. It is the kind of check that shows up in homework helpers, unit-conversion pipelines and pricing engines, done in one deterministic call instead of a hand-rolled comparison that quietly breaks at the edge cases.
What the comparison returns
You send four integers: the numerator and denominator of the first fraction and the numerator and denominator of the second. A comparison of -1 means the first fraction is smaller, 0 means the two fractions represent exactly the same value, and 1 means the first fraction is larger. Because 1/2 and 2/4 are the same value, comparing them returns 0 — equality is about the value, not about the digits looking alike.
Alongside the verdict you also get each fraction echoed back with its decimal value, which is handy for displaying the result but is never what decides it: the decision itself is made with exact arithmetic, so the decimal shown is a convenience, not the mechanism.
Why exact cross-multiplication matters
The naive way to compare a/b and c/d is to divide both and compare the decimals. That works until the numbers get large enough that two different fractions round to the same floating-point value — or the same fraction rounds two different ways on two different machines. This capability instead compares the cross products a×d and c×b as exact integers, which is mathematically equivalent to comparing the fractions and involves no division at all, so there is no rounding error at any magnitude.
Negative values behave the way mathematics says they should: -1/2 is smaller than 1/3, and a negative denominator simply makes the whole fraction negative, so 1/-2 compares exactly like -1/2. Zero numerators are fine and compare equal to any other zero-valued fraction. The only inputs rejected outright are zero denominators, because a fraction with a zero denominator is undefined, and non-integer values, because the contract is about exact integer fractions.
Where it fits in a pipeline
Teams use it wherever a fractional threshold has to be evaluated exactly: a discount engine that must decide whether 2/3 of a quota has been consumed, an educational tool that checks a student's answer against the correct ordering, or a data-cleaning step that normalizes ratios stored as separate numerator and denominator columns. And because the verdict is a plain -1, 0 or 1, it drops straight into any sorting callback, assertion or conditional branch without further parsing or unit conversion on your side.
What you can do with it
Check a homework answer
Verify whether a student's ordering of two fractions is correct, including the equal case like 3/9 versus 1/3.
Evaluate a fractional threshold
Decide whether a ratio stored as numerator and denominator columns has crossed a reference fraction, exactly, without floating-point drift.
Normalize ratios before sorting
Compare ratios pairwise with exact integer arithmetic so a sorted report orders 5/8 and 62/100 correctly every time.
FAQ
What do the return values mean?
-1 means the first fraction is smaller, 0 means both fractions are equal and 1 means the first fraction is larger.
Can numerators or denominators be negative?
Yes. Negative values are compared with correct mathematical sign handling, so 1/-2 compares exactly like -1/2.
Is the comparison exact for very large numbers?
Yes. The fractions are compared by exact integer cross-multiplication, not by dividing into decimals, so there is no rounding error at any magnitude.
Are 1/2 and 2/4 reported as equal?
Yes. Equality is about the value of the fraction, not the literal numbers, so equivalent fractions return 0.
How do you compare two fractions without dividing?
Multiply crosswise and compare the two products. For 3/4 and 2/3, 3 × 3 is 9 and 2 × 4 is 8, so 3/4 is larger. With no division there is no rounding, however big the numbers get.
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/math/comparing-fractions \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"numerator_1":3,"denominator_1":4,"numerator_2":2,"denominator_2":3}'const res = await fetch("https://api.kit.forhosting.com/math/comparing-fractions", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"numerator_1": 3,
"denominator_1": 4,
"numerator_2": 2,
"denominator_2": 3
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/math/comparing-fractions",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"numerator_1": 3,
"denominator_1": 4,
"numerator_2": 2,
"denominator_2": 3
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/math/comparing-fractions", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"numerator_1":3,"denominator_1":4,"numerator_2":2,"denominator_2":3}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"numerator_1":3,"denominator_1":4,"numerator_2":2,"denominator_2":3}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/math/comparing-fractions", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"numerator_1": 3,
"denominator_1": 4,
"numerator_2": 2,
"denominator_2": 3
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "math.comparing_fractions",
"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
The compare fractions API takes two fractions — each given as an integer numerator and denominator — and tells you which one is larger, returning -1 when the first is smaller, 0 when they are equal and 1 when the first is larger.
What the comparison returns
The endpoint answers with a single number, comparison, plus a human-readable larger field that says whether the first fraction, the second fraction or neither is bigger.
Where it fits in a pipeline
Because the function is deterministic, side-effect free and identical in the browser and on the server, you can prototype a check on this page for free and then automate the exact same comparison through the API without worrying that the two environments will disagree. Each call costs $0.002, with no surcharge for large integers — the work is a constant-time pair of multiplications regardless of how many digits the inputs have, so a budget built on small test values extrapolates safely to production data.
Technical questions
What does it cost?
$0.002 per request. It is also free to run in your browser on this page.
What happens if a denominator is zero?
The request is rejected with an invalid_input error, because a fraction with a zero denominator is undefined.