Change of base calculator
Get a logarithm in any base, not just ln or log10: log base 10 of 1000 is 3, worked out as ln 1000 divided by ln 10. Both natural logarithms are shown, so you can copy the full step into your work. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Value
- 1,000
- Base
- 10
- Logarithm
- 3
- Ln value
- 6.907755279
- Ln base
- 2.302585093
log in any base from value and base
What the change of base formula is and when you need it
A logarithm answers the question: to what power must I raise this base to get this value? The answer exists for any positive base other than one, but in practice you can rarely compute it directly. Scientific calculators ship with keys for ln and log10 only, and standard libraries in JavaScript, Python or C expose exactly the same two.
You need it whenever the base is dictated by the problem rather than by your calculator — bits in information theory use base 2, musical intervals use base 2 as well, pH and decibels live in base 10, and continuous growth lives in base e. Instead of looking the formula up each time and dividing by hand, you send the value and the base here and receive the logarithm computed through that exact identity, with both natural logarithms included in the response so the derivation is auditable.
The change of base formula is therefore not an approximation but an exact identity, and the only numerical error involved is ordinary floating-point rounding.
How the calculation works, step by step
Both must be finite numbers; numeric strings such as "0.5" or "1e3" are accepted too. The value must be strictly greater than zero, because logarithms of zero and of negative numbers are not defined in the real numbers. The base must also be strictly greater than zero and must not equal one — base 1 is excluded because 1 raised to any power stays 1, so its logarithm is meaningless.
A result of log base 2 of 8 comes back as 3, with ln(8) ≈ 2.07944154168 and ln(2) ≈ 0.69314718056 alongside it, so a student can copy the full worked step into an assignment and an engineer can verify the pipeline against a hand computation.
Practical uses, pricing and determinism
Change of base shows up in more places than a math class. Information theory measures entropy in bits with base-2 logarithms; doubling-time problems in finance and biology solve for an exponent in whatever base the growth factor dictates; algorithm analysis compares growth rates across bases knowing they differ only by a constant factor — which is itself a change of base.
This capability is deliberately small and deterministic: the same input always produces byte-identical output, there is no network call, no clock and no randomness involved, and results are rounded to twelve significant digits so they are stable across machines. For batch work, send one request per pair of value and base; the operation is cheap enough that even large batches cost fractions of a cent.
What you can do with it
Compute a base-2 logarithm for information theory
Get log2 of a probability or a count for entropy and bits-of-information calculations that no ln or log10 key can produce directly.
Show the worked step in homework
Copy the returned ln(value) and ln(base) into an assignment to demonstrate the change of base formula, not just the final answer.
Solve doubling and halving problems
Find how many periods a growth or decay factor needs by taking the logarithm in the base the problem gives you.
FAQ
Which inputs are valid?
A positive finite value, and a base that is positive, finite and not equal to 1.
Why is base 1 rejected?
Because 1 raised to any power is still 1, so a logarithm with base 1 has no meaningful answer.
Can it compute natural or base-10 logarithms?
Yes: pass e (2.718281828459045) or 10 as the base. The formula is the same in every case.
How accurate is the result?
It uses the platform's double-precision Math.log and rounds to twelve significant digits, so results are stable and reproducible across machines.
Does the formula only work with natural logarithms?
No. The ratio comes out the same with base-10 logarithms on top and bottom, so either pair gives the same answer. Natural logarithms are used here, and both are shown so the step can be checked by hand.
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/change-of-base \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"value":1000,"base":10}'const res = await fetch("https://api.kit.forhosting.com/math/change-of-base", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"value": 1000,
"base": 10
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/math/change-of-base",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"value": 1000,
"base": 10
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/math/change-of-base", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"value":1000,"base":10}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"value":1000,"base":10}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/math/change-of-base", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"value": 1000,
"base": 10
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "math.change_of_base",
"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 change of base API computes a logarithm in any base you choose, directly from the value and the base. Most calculators and programming languages only offer the natural logarithm and the base-10 logarithm, so any other base — 2, 7, 0.5, e² — has to go through the change of base formula: log_base(value) = ln(value) / ln(base). This endpoint applies exactly that formula, and it returns not only the logarithm itself but also the two natural logarithms used in the division, so you can see every step of the computation instead of a bare number. It runs the same deterministic code in your browser for free as it does behind the paid API, at $0.002 per request.
What the change of base formula is and when you need it
The change of base formula bridges that gap: log_base(value) equals ln(value) divided by ln(base), and it works equally well with log10 on both sides.
How the computation works and what the response contains
The endpoint accepts two fields: value, the number whose logarithm you want, and base, the base of the logarithm. When the input passes validation, the code computes the natural logarithm of the value and of the base, divides the first by the second, and returns an object with the value, the base, the resulting logarithm, the two intermediate natural logarithms, and the formula itself as a string. Invalid input is rejected with a clear invalid_input error and is never charged.
Practical uses, pricing and determinism
The same module that powers the API runs free in your browser on this page, which means the free web result is exactly what the paid API returns — identical code, identical numbers. You only pay when you automate it from your own software, at $0.002 per request.
Technical questions
What does it cost?
$0.002 per request via the API. It is also free to run in your browser on this page, with identical results.
What happens with invalid input?
You get an invalid_input error explaining which field is wrong and what was expected. Invalid requests are never charged.