*This is the documentation of Template:dec to frac.*

This template employs intricate features of template syntax. You are encouraged to familiarise yourself with its setup and parser functions before editing the template. If your edit causes unexpected problems, please undo it quickly, as this template may appear on a large number of pages. Remember that you can conduct experiments, and should test all improvements, in either the general Template sandbox or your user space before changing anything here. |

This template converts a decimal fraction to a vulgar fraction which is equal to the result of rounding to a multiple of one divided by a given denominator. It takes two parameters:

- fraction to be converted;
- resulting vulgar fraction's denominator

If the decimal fraction includes an integer part, it is retained in the output. If the resulting vulgar fraction can be resolved in lower terms than specified denominator, it is resolved, but due to algorithm limitation fractions with relatively large nominators/denominators may be left unresolved.

## Examples

- {{dec to frac|0.375|16}} →
^{3}⁄_{8} - {{dec to frac|0.375|100}} →
^{19}⁄_{50} - {{dec to frac|3.6742|16}} → 3
^{11}⁄_{16} - {{dec to frac|3.99|8}} → 4
- {{dec to frac|3.1|2}} → 3

To reduce rounding errors, increase the denominator:

- {{dec to frac|0.375|1000}} →
^{3}⁄_{8} - {{dec to frac|3.6742|64}} → 3
^{43}⁄_{64} - {{dec to frac|3.99|80}} → 3
^{79}⁄_{80} - {{dec to frac|3.1|10}} → 3
^{1}⁄_{10}

Community content is available under CC-BY-SA
unless otherwise noted.