الگو:Rnd

الگو به طور دائم حفاظت‌شده است
از ویکی‌پدیا، دانشنامهٔ آزاد
توضیحات الگو[نمایش] [ویرایش] [تاریخچه] [پاکسازی]

Usage

This template rounds {{{1}}} to {{{2}}} decimal places (goes the other way for negatives) and includes trailing zeros. Scientific notation is used for numbers greater than or equal to 1‎×۱۰۹, or less than 1‎×۱۰−۴.

Compare:

  • {{rnd|2.0004|3}} gives ۲٫۰۰۰
    • whereas {{#expr:2.0004 round 3}} gives 2
  • {{rnd|0.000020004|7}} gives ۲٫۰۰×۱۰−۵
  • {{rnd|0|8}} gives ۰٫۰۰۰۰۰۰۰۰
  • {{rnd|154268|-3}} gives ۱۵۴۰۰۰
  • {{rnd|1200004|-1}} ← ۱۲۰۰۰۰۰
  • {{rnd|1300004|-1}} ← ۱۳۰۰۰۰۰
  • {{rnd|4.1e6|9}} ← ۴۱۰۰۰۰۰٫۰۰۰۰۰۰۰۰۰
  • {{rnd|4.1e6|10}} ← ۴۱۰۰۰۰۰٫۰۰۰۰۰۰۰۰۰۰
  • {{rnd|1542689271|-7}} ← ۱۵۴۰۰۰۰۰۰۰
          ×۱۰
  • {{rnd|1542689271|2}} ← ۱۵۴۲۶۸۹۲۷۱
          ×۱۰۲
          
  • {{rnd|7e9|-9}} ← ۷۰۰۰۰۰۰۰۰۰
          ×۱۰
  • {{rnd|-123|1}} ← −۱۲۳٫۰
  • {{rnd|-1200007|-2}} ← −۱۲۰۰۰۰۰
  • {{rnd|-1234567899|-7}} ← −--۱۲۳۰۰۰۰۰۰۰
             ×۱۰

As with #expr, the total number of significant digits is not more than 14:

  • {{rnd|1234567890.123456789|10}} ← ۱۲۳۴۵۶۷۸۹۰٫۱۲۳۵
          ×۱۰۱۰
          
  • {{rnd|123456789.0123456789|10}} ← ۱۲۳۴۵۶۷۸۹٫۰۱۲۳۵۰۰۰۰۰
  • {{rnd|.0001234567890123456789|20}} ← ۰٫۰۰۰۱۲۳۴۵۶۷۸۹۰۱۲۳۵

Internal details

The template uses three subtemplates:

  • {{rnd/-}} — for trailing zeros
  • {{rnd/e+}} — for scientific notation for numbers greater than or equal to 109 or less than or equal to −109
  • {{rnd/e−}} — for scientific notation for numbers greater than −10−4 and less than 10−4 but not equal to zero

See also