Skabelon:Round
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 significant digits, 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 "123.456" [1]"{{round|123.456|3}}"gives "123.456" [2]"{{round|123.456|2}}"gives "123.46" [3]"{{round|123.456|1}}"gives "123.5" [4]"{{round|123.456|0}}"gives "123" [5]"{{round|123.456|-1}}"gives "120" [6]"{{round|123.456|-2}}"gives "100" [7]"{{round|123.456|-3}}"gives "0" [8]
"{{round|123456.789}}"→ "123457" [9]"{{round|12345.6789}}"→ "12346" [10]"{{round|1234.56789}}"→ "1235" [11]"{{round|123.456789}}"→ "123.5" [12]"{{round|12.3456789}}"→ "12.35" [13]"{{round|1.23456789}}"→ "1.235" [14]"{{round|.123456789}}"→ "0.123" [15]"{{round|.0123456789}}"→ "0.012" [16]"{{round|.00123456789}}"→ "0.001" [17]
Note that trailing zeros are not shown, so rounding can seem cruder than has actually been applied:
While this is a limitation of the template (normally there would be trailing zeros to show the precision), 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}}"→ "1230" [21]
Se også
- {{roundup}}
- {{rounddown}} – en:Template: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"
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.









