This templates rounds parameter 1 to the number of digits after the point optionally given as parameter 2. If parameter 2 is negative, rounding is to a multiple of 10. If parameter 2 is undefined, numbers with 4 digits before the point are rounded to integers, numbers with 3 digits before the point are rounded to 1 digit after the point, numbers with 2 digits before the point are rounded to 2 digits after the point, and numbers with 1 digit before the point or none are rounded to 3 digits after the point.

In other words, if parameter 2 is undefined, rounding is to 4 ارقام قابل توجه, except that it is not cruder than rounding to an integer and not finer than rounding to three digits after the decimal point.

Examples:

  • "{{round|123.456|4}}" gives "۱۲۳٫۴۵۶۰" [۱]
  • "{{round|123.456|3}}" gives "۱۲۳٫۴۵۶" [۲]
  • "{{round|123.456|2}}" gives "۱۲۳٫۴۶" [۳]
  • "{{round|123.456|1}}" gives "۱۲۳٫۵" [۴]
  • "{{round|123.456|0}}" gives "۱۲۳" [۵]
  • "{{round|123.456|-1}}" gives "۱۲۰" [۶]
  • "{{round|123.456|-2}}" gives "۱۰۰" [۷]
  • "{{round|123.456|-3}}" gives "۰" [۸]
  • "{{round|123456.789}}" → "۱۲۰۰۰۰" [۹]
  • "{{round|12345.6789}}" → "۱۲۰۰۰" [۱۰]
  • "{{round|1234.56789}}" → "۱۲۰۰" [۱۱]
  • "{{round|123.456789}}" → "۱۲۰" [۱۲]
  • "{{round|12.3456789}}" → "۱۲" [۱۳]
  • "{{round|1.23456789}}" → "۱٫۲" [۱۴]
  • "{{round|.123456789}}" → "۰٫۱۲" [۱۵]
  • "{{round|.0123456789}}" → "۰٫۰۱۲" [۱۶]
  • "{{round|.00123456789}}" → "۰٫۰۰۱۲" [۱۷]

Note that trailing zeros are not shown, so rounding can seem cruder than has actually been applied:

  • "{{round|123.04}}" → "۱۲۰" [۱۸]
  • "{{round|12.304}}" → "۱۲" [۱۹]
  • "{{round|1.2304}}" → "۱٫۲" [۲۰]

While this is a limitation of the template (normally there would be trailing zeros to show the ارقام قابل توجه), there is also the general problem that if a number is an integer with trailing zeros, then the precision is not clear:

  • "{{round|1230.4}}" → "۱۲۰۰" [۲۱]

See also ویرایش

  • {{roundup}}
  • {{rounddown}}
  • {{decimals}} – acts like rounding but displays trailing zeros after the decimal point
  • {{precision}} – handles rounding of large numbers, too, like "349,030,293" → "349,030,000", "349,000,000", or "350,000,000"

TemplateData ویرایش

این، توضیحاتِ الگوداده است که توسط TemplateWizard، ویرایشگر دیداری و دیگر ابزارها استفاده می‌شود. گزارش خطای ماهیانه برای این الگو را ببینید.

الگوداده Round

This templates rounds a value to the optionally given number of digits after the point.

پارامترهای الگو

پارامترتوضیحاتنوعوضعیت
Value1

The value to be rounded

مثال
3.14159265
شمارهضروری
Number of digits2

Number of digits after the point. If negative, rounding is to a multiple of 10. If undefined, numbers with 4 digits before the point are rounded to integers, numbers with 3 digits before the point are rounded to 1 digit after the point, numbers with 2 digits before the point are rounded to 2 digits after the point, and numbers with 1 digit before the point or none are rounded to 3 digits after the point.

مثال
2
شمارهاختیاری