Decimal-to-Fraction Converter (DFC)
As opposed to KFC, this is DFC.
We can simply type or paste the number on the first input ➡️ hit Enter
➡️ bam!
The next input is for our own maximum denominator value, default is 1,000
. The range for this input is 1
to 1e11
(1 × 10¹¹, one hundred billion) — it is used to converge a decimal to a rational approximation (i.e. to find the "best fraction" representation of a decimal number within the limit of a maximum denominator).
Remember to hit Enter
button every time we change either input to trigger the conversion.
We can try 3.1416
or 3.14159
, an approximation for π
(pi) — credit to Master Liu Hui (3rd-century Chinese mathematician). The century is using Gregorian, not Confucian. Hence, 3rd. Chinese calendar runs in 60-year cycles, using a combination of the Ten Heavenly Stems (天干) and Twelve Earthly Branches (地支). Take that, paper and pencil. But get this, Master Liu Hui lived in Three Kingdoms era.
About
DFC converts a decimal into a fraction by using the convergent method,
which builds up increasingly accurate fractions through a stepping process.
It stops once the denominator reaches 1,000
or our own limit (range: 1
- 1e11
), ensuring the result stays simple and readable.
So, for example, with 1,000
as the maximum denominator, 0.333
becomes
\( \frac{333}{1000} \)
because that's already neat and within the limit — but
0.3333
gets converted to
\( \frac{1}{3} \),
since
\( \frac{1}{3} \)
is a better, cleaner fraction that still fits the allowed size.
This approach balances accuracy and simplicity. 😃
DFC employs Number.EPSILON
to do the floating-point comparison. Number.EPSILON
= the smallest difference between 1 and the next larger representable floating-point number. In IEEE-754 double precision (which JS uses), that's about 2.220446049250313 × 10¯¹⁶
.
Like this:
function nearlyEqual(a, b) {
return Math.abs(a - b) < Number.EPSILON;
}
Because in JS, using ===
operator:
0.1 + 0.2 === 0.3 // is false.
But when use the Number.EPSILON
:
nearlyEqual(0.1 + 0.2, 0.3) // is true.
Ep-bladdy-silon
Epsilon in Greek means, well, "epsilon". But in English, "a tiny thing" — because mathematicians can't resist nicking Greek letters.
In a pub conversation:
(Silent.)
Derailment
Once upon a time, KFC did mean Kentucky to Fried Chicken.
Uh-huh, with the to.
How long to get from Kentucky to Fried Chicken? 🤔🤷
It's arbitrary, aye? We could get bajillion scenarios. If the Fried Chicken is an actual place in Kentucky, well... Still, what part of Kentucky is the starting point? 🤦
Are you hungry now? 🍗🥤
— Credits to those bravely blissful hens who gave their thighs to fill our thighs in glory.
It's like that song from Michelle Branch, "Are You Hungry Now?", that? You did listen to that, did you not? It sounded so melancholically angry.
Are you hungry now? 😤💢💃 (Crumbling building and such.) Indeed, Michelle didn't dance in the music video, the mellancholy was the combination of the jive of the music and lyrics, plus her stare. And perhaps her hidden fiery fists. "Could you look me in the eye?", indeed. 🙈
We can try to relisten to Michelle's 2000s exquisiteness, and convert the "happy" to "hungry" in our minds.
Michelle Branch - Breathe ⬅️ Instead of "breathe", I sometimes heard "bleed". Blimey! 😲 Neat guitar rhythm and vibe though — I was sudden-hooked by the intro riff. But at around 2:00
timestamp in the music video, we should see the bassist's surprised-dubstep. Everything is alright, mate.
Use DFC as Your Reference
DFC can directly convert the number using URL parameter. ?number=YOUR_NUMBER
As such:
https://portraptor.johanpaul.net/2025/09/decimal-to-fraction-converter-dfc.html?number=0.23
Example, in anchor
tag:
<a
href="https://portraptor.johanpaul.net/2025/09/decimal-to-fraction-converter-dfc.html?number=0.23"
target="_blank"
rel="noopener"
title="Open new tab">
Fraction form for 0.23
</a>
The URL template is like so:
https://portraptor.johanpaul.net/2025/09/decimal-to-fraction-converter-dfc.html?number=YOUR_NUMBER
Template in anchor
tag:
<a
href="https://portraptor.johanpaul.net/2025/09/decimal-to-fraction-converter-dfc.html?number=YOUR_NUMBER"
target="_blank"
rel="noopener"
title="Open new tab">
YOUR LINK TEXT
</a>
Adding Max Denominator
We can also add the maxDen
URL parameter for the maximum value for the denominator, as in &maxDen=YOUR_OTHER_NUMBER
. The range is 1
to 1e11
.
So it could be added as such:
https://portraptor.johanpaul.net/2025/09/decimal-to-fraction-converter-dfc.html?number=YOUR_NUMBER&maxDen=YOUR_OTHER_NUMBER
This blue lad is one of the background stunts in that "accusatory-confirmative rhetorical question with pragmatic force behind it" song. Are you hungry now? Uh, I was. But, you're looking at me like being constipated and sitting on posterior-boils with clenched fists. 🤔
Thank you for visiting. 🙂
This is a related post on Monkey Raptor on how to do it using pencil and paper.