repeating-decimal
v0.0.3
Published
Convert repeating decimals into exact fractions
Maintainers
Readme
repeating-decimal
Convert repeating decimals into Fractions.
This package provides a utility to convert numbers with repeating parts(e.g. 0.987123123123...=41089/41625) into a reduced fractional representation.
Warning
There is currently a bug that may prevent numbers from being generated correctly if they contain zeros.
Features
- Convert repeating decimals to fractions
- Supports arbitrary bases (2–36)
- Fully written in TypeScript
- ESM-compatible
- No external runtime dependencies
Installation
npm install repeating-decimal Usage
import { make_fraction } from "repeating-decimal";
const result = make_fraction(
{
integer:0,
leading_decimal:"009",
repeating_decimal:"123"
},
10
);
console.log(result);
// {numerator: 1519,denominator: 166500}
// 1519/166500=0.009123123...