Golden ratio base converter
2 becomes 10.01 in base φ, where each place is a power of phi, about 1.61803398875: every whole number gets a finite string of only 0 and 1, often with digits after the point. Convert decimal to base φ and back. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Value
- 2
- Direction
- To phi
- Result
- 10.01
- Decimal
- 2
- Base phi
- 10.01
- Alphabet
- 01
Every place is a power of φ, and the only digit symbols needed are zero and one. Integers that look ordinary in base ten often need a fractional part in base φ: the classic classroom check is that two becomes one-zero point zero-one in base φ, and that string evaluates back to two exactly. Invalid characters, empty input, and non-finite values fail with a clear invalid-input error instead of a silent wrong answer.
How converting to and from base φ works
Because φ satisfies the identity φ squared equals φ plus one, powers of φ obey the same linear recurrence as the Fibonacci sequence: every integer power φ to the k can be written exactly as F_k times φ plus F_{k−1}. That identity is why every non-negative integer has a finite representation using only digits zero and one, often with digits after the radix point.
Classic checks from the literature include one encoding to one, two encoding to ten point zero one, three encoding to one hundred point zero one, four encoding to one zero one point zero one, and five encoding to one thousand point one zero zero one.
To encode a finite decimal number, a greedy algorithm finds the largest power of φ that does not exceed the remaining value, places a one in that place, subtracts the place value, and continues down through a fixed number of fractional places until the residual is negligible. Leading zeros before the point and trailing zeros after the point are stripped so the string is compact; zero itself is the single digit zero. Negative inputs keep a leading minus on the digit string the same way decimal does.
To decode, strip an optional zero-phi prefix or phi suffix, then evaluate each digit times the matching power of φ and sum them—Horner-style accumulation from the left works too. Non-canonical strings that contain consecutive ones are still accepted on decode because eleven in base φ equals one hundred in base φ by the defining identity; the encoder prefers the greedy form without relying on a separate rewrite pass.
Invalid characters such as digit two, letters other than an allowed prefix or suffix, spaces inside the body, or more than one radix point abort with invalid input naming the problem.
What you can do with it
Non-integer base lessons
Convert homework values between base-10 and base φ so students see finite 0/1 expansions for ordinary integers such as 2 → 10.01_φ.
Exam and LMS auto-grading
Mark phinary encode/decode items with a deterministic oracle that rejects invalid digits and never invents a digit outside 0 and 1.
FAQ
Why does 2 become 10.01 instead of 10?
In base φ, place values are powers of φ ≈ 1.618, not powers of two. The string 10_φ equals φ ≈ 1.618, not 2. Adding φ^(−2) gives 10.01_φ = φ + 1/φ² = 2 exactly.
What is base φ, also called phinary?
It is a positional system whose base is phi, about 1.61803398875. Each place is a power of φ and the only digits are 0 and 1. Because phi squared equals phi plus one, every whole number has a finite base φ form.
How do I convert a base φ string back to decimal?
Multiply each digit by the power of φ for its place and add the results: 10.01 gives back exactly 2. An optional 0phi prefix or φ suffix is removed first, and only one radix point is allowed.
Why does decoding accept 11 in base φ?
Because phi squared equals phi plus one, 11 in base φ is worth exactly the same as 100. Decoding accepts strings with consecutive ones, while encoding writes the greedy form, always placing the largest power that fits first.
Can I convert negative numbers or fractions to base φ?
Yes. A negative number keeps its leading minus, and decimals with a fractional part or in scientific notation are accepted. The result is built over a fixed number of places after the point, so some values are rounded, and extremely large ones are rejected.
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/enc/base-phi \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"value":"2","direction":"to_phi"}'const res = await fetch("https://api.kit.forhosting.com/enc/base-phi", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"value": "2",
"direction": "to_phi"
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/enc/base-phi",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"value": "2",
"direction": "to_phi"
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/enc/base-phi", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"value":"2","direction":"to_phi"}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"value":"2","direction":"to_phi"}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/enc/base-phi", 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": "2",
"direction": "to_phi"
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "enc.base_phi",
"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
Successful API calls use the published base of $0.002 per item.
How base φ (golden ratio base) encoding and decoding work
The algorithm uses only deterministic floating-point arithmetic capped by maximum power and fractional place limits: no random seeds, no wall-clock timestamps, and no network calls, so identical inputs always produce identical JSON within the documented rounding of the decimal field.
What you send and what you get back
Send two required fields: value and direction. Extremely large magnitudes that would need powers beyond the safety cap are rejected so results stay finite and comparable across runtimes. Classic round-trips include two encoding to ten point zero one and decoding back to two, and ten point zero one decoding to two. Direction must be to_phi when value is a finite decimal number, or from_phi when value is a base-φ digit string. Aliases are accepted so forms and scripts can use the names that fit their UI: value also accepts n, number, input, text, decimal, phi, base_phi, and phinary; direction also accepts dir, mode, and op, plus short synonyms such as to, from, encode, decode, to_base_phi, from_base_phi, decimal_to_phi, and phi_to_decimal. For to_phi, value may be a JSON number or a numeric string with an optional leading plus or minus, an optional fractional part, or scientific notation; NaN, Infinity, bare words, empty strings, and non-numeric text fail with invalid_input and are not charged. For from_phi, every body character must be zero, one, or a single radix point after an optional sign and an optional zero-phi prefix; any other character—including two, three, underscore mid-string, space, or a second point—fails with a message that names the invalid base-φ digit and its position when possible. On success the response echoes the cleaned value string, the normalized direction, decimal as a rounded number, base_phi as the compact phinary string, result as the primary converted form (base_phi when encoding, decimal string when decoding), the alphabet string zero-one, base set to the token phi, the numeric constant phi rounded for display, and digit_count for the digit body without the sign or point. Pricing for successful API calls is the published base of $0.002 per item; validation failures do not consume prepaid balance.
Where a golden ratio base converter earns its keep
Number-theory and recreational-math courses introduce base φ to show that a non-integer radix can still give every natural number a finite expansion with a binary alphabet, which surprises students who only ever convert between integer bases two through thirty-six. Exam-prep generators and LMS plugins need a deterministic oracle that marks wrong a binary decode of a string that was meant as phinary, and that never invents a digit two. Because this capability is a pure parse engine, API pricing is the published base of $0.002 per successful item and failed validation does not consume balance.
Integration use cases
Puzzle keys and unit-test fixtures
Generate expected base-φ strings for competitive-programming samples and multi-base UI tests, including fractional parts and negatives.
Technical questions
What is the golden ratio base (base φ)?
Base φ is positional notation with radix φ = (1+√5)/2 and digits 0 and 1 only. Place values are powers of φ. Every non-negative integer has a finite representation, often with digits after the point (for example 2 = 10.01_φ).
How do I convert a decimal number to base φ?
Send direction to_phi and value as a finite number (JSON number or numeric string with optional +/− and fraction). The API returns the base-φ digit string in the base_phi and result fields.
How do I decode a base-φ string back to decimal?
Send direction from_phi and value as a string of digits 0 and 1 with at most one radix point (optional sign, optional 0phi prefix or _phi suffix). The API returns the decimal number in decimal and result.
What does the golden ratio base converter cost?
The browser tool is free. API requests use prepaid KIT balance at $0.002 per successful call; invalid input is not billed.