Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
readable-fractions
Advanced tools
Converts decimals to human readable fractions, and fractions to decimals.
A small library to convert decimals to human readable fractions. Since the fractions are human readable, it means that they are not precise. The maximum denominator (right now) is 10. Also contains a function to convert fractions to decimals.
Formats the readable fraction object as a string.
Usage:
let fractionObject = {
denominator: 3,
error: -3.3333333332441484e-7,
numerator: 1
};
let result = formatReadableFraction(fractionObject);
console.log(result);
// '1/3'
let fractionObject = {
denominator: 5,
error: -0.012500000000000178,
numerator: 11
};
let result = formatReadableFraction(fractionObject);
console.log(result);
// '2 1/5'
let fractionObject = {
denominator: 5,
error: -0.012500000000000178,
numerator: 11
};
let result = formatReadableFraction(fractionObject);
console.log(result);
// '11/5'
Converts a fraction to a decimal. Unlike toReadableFraction, this is precise.
Usage:
let fraction = '1/4';
let result = fractionToDecimal(fraction);
console.log(result);
// 0.25
let fraction = '2 1/4';
let result = fractionToDecimal(fraction);
console.log(result);
// 2.25
Converts a decimal to a human readable fraction with a maximum denominator of 10. This means that the result is NOT precise.
Usage:
let decimal = 0.333333;
let result = toReadableFraction(decimal);
console.log(result);
// { denominator: 3, error: -3.3333333332441484e-7, numerator: 1 }
let decimal = 0.125;
let result = toReadableFraction(decimal, true);
console.log(result); // '1/8'
Add the git post-commit hook
MIT
FAQs
Converts decimals to human readable fractions, and fractions to decimals.
The npm package readable-fractions receives a total of 1,166 weekly downloads. As such, readable-fractions popularity was classified as popular.
We found that readable-fractions demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.