ferraridamiano / ConverterNOW

The Unit Converter app: easy, immediate and multi-platform
https://converter-now.web.app
GNU General Public License v3.0
388 stars 63 forks source link

[new-unit] Fractions to Decimal Representation #201

Open fohfuu opened 1 year ago

fohfuu commented 1 year ago

Description Fractions to decimals and decimals to fractions is useful in many circumstances - Arithmetic, circle geometry and converting non-decimal measurement systems to metric (i.e. issue #148), etc. It is a standard on scientific calculators for this reason.

Units to be added Unit name Property Reference to the conversion formula
Fractions Numeral System link
ferraridamiano commented 1 year ago

If issue #148 will be fixed, this unit is redundant, isn't it?

fohfuu commented 1 year ago

I would like an option that converts decimal to fraction and vice versa on its own.

For one, most converted units would be displayed as mixed fractions - like $1^1/_2$". Taking the mixed fraction and converting back it to an improper fraction - $(1×3)+ ^1/_3 = ^3/_2$ - adds an unnecessary layer of effort.

But, for two, this makes the converter more versatile for a variety of situations. Various sciences use fractions due to the difficulties of rational numbers that can only be represented with reptends (infinitely repeating decimals). I can find some examples of how they're used in chemistry, if needs be, but to choose a simpler example, they can also represent ratios.

Aspect Ratio

A screen is 720x1280. To find the aspect ratio of this screen: > $720÷1280=1.77777777$ Then convert decimals to fractions: | Input | | --- | | 1.77777777 | | Repeating digits | | 8 | | Output | | --- | | $^{16}/_9$ | So the aspect ratio is 16:9.

You can see an example of a Decimal to Fraction converter here: Decimal To Fraction Calculator

The creator chose to leave an option for users to specify the number of repeating digits:

0.8333... repeating

| Input | | --- | | 0.83333333 | | Repeating digits | | 7 | | Output | | --- | | $^5/_6$ |

0.333... repeating

| Input | | --- | | 0.3 | | Repeating digits | | 1 | | Output | | --- | | $^1/_3$ |

However, there are a thousand ways to implement this sort of function, with more or less complexity. The average scientific calculator doesn't allow the user to specify the repeating digits and still does the job. It depends on how you would want to implement it.

Apologies for the multiple edits - I'm on a device that doesn't support Github's maths formatting, so I'm doing it all by hand.

bagnacauda commented 1 year ago

I would like to have this feature implemented too. Sometimes it just makes more sense to enter a fraction, and readability is much improved also.