跳去內容

Template:Dec to frac

出自維基百科,自由嘅百科全書
模解[] [] [] []

呢個模包含最少一個可選參數:用之前唔該睇下討論頁


呢個模用咗一啲好複雜嘅語法同好多秘技。響你明嗮佢嘅用途同構造之前,千祈唔好喐佢。亦都要有心理準備要補返嗮改錯咗嘅地方。所有實驗都唔該喺沙盤模,或者你個用戶頁入面搞。

This template converts decimal fractions to vulgar fractions. 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 numerators/denominators may be left unresolved.

Examples

[編輯]
  • {{dec to frac|3.6742|16}} → 31116
  • {{dec to frac|0.375|16}} → 38

Sometimes it is impossible to convert a decimal to a vulgar fraction with requested denominator, in which cases the output is simply an input rounded up:

  • {{dec to frac|3.99|8}} → 4

...or down:

  • {{dec to frac|3.1|2}} → 3

When that is unacceptable, increase the denominator:

  • {{dec to frac|3.99|100}} → 399100
  • {{dec to frac|3.1|10}} → 3110

睇埋

[編輯]