Template:Round
From Wikizilla, the kaiju encyclopedia
Jump to navigationJump to search
This template takes a number and rounds it.
- {{round|12.25}} -> 12
- {{round|12.49}} -> 12
- {{round|12.50}} -> 13
- {{round|12.51}} -> 13
- {{round|12.75}} -> 13
Adding a second field, you can specify a number of decimal places to round to.
- {{round|1.23456789|1}} -> 1.2
- {{round|1.23456789|2}} -> 1.23
- {{round|1.23456789|3}} -> 1.235
- {{round|1.23456789|4}} -> 1.2346
- {{round|1.23456789|5}} -> 1.23457
- {{round|1.23456789|6}} -> 1.234568
- {{round|1.23456789|7}} -> 1.2345679
- {{round|1.23456789|8}} -> 1.23456789
- {{round|1.23456789|9}} -> 1.23456789
Using negative numbers, you can specify a number of significant figures to use.
- {{round|123456789.9|-1}} -> Expression error: Unexpected < operator.
- {{round|123456789.9|-2}} -> Expression error: Unexpected < operator.
- {{round|123456789.9|-3}} -> Expression error: Unexpected < operator.
- {{round|123456789.9|-4}} -> Expression error: Unexpected < operator.
- {{round|123456789.9|-5}} -> Expression error: Unexpected < operator.
- {{round|123456789.9|-6}} -> Expression error: Unexpected < operator.
- {{round|123456789.9|-7}} -> Expression error: Unexpected < operator.
- {{round|123456789.9|-8}} -> Expression error: Unexpected < operator.
- {{round|123456789.9|-9}} -> Expression error: Unexpected < operator.
Specifying "up" or "down" in the final parameter truncates or increases the number.
- {{round|12.25|up}} -> 13
- {{round|12.25|down}} -> 12
- {{round|12.49|up}} -> 13
- {{round|12.49|down}} -> 12
- {{round|12.50|up}} -> 13
- {{round|12.50|down}} -> 12
- {{round|12.51|up}} -> 13
- {{round|12.51|down}} -> 12
- {{round|12.75|up}} -> 13
- {{round|12.75|down}} -> 12
Specifying decimals places/significant figures and which way to round can work together, as long as which way to round comes after the dp/sf.
- {{round|5555.5555|4|down}} -> 5555.5555
- {{round|5555.5555|3|down}} -> 5555.555
- {{round|5555.5555|2|down}} -> 5555.55
- {{round|5555.5555|1|down}} -> 5555.5
- {{round|5555.5555|-1|down}} -> Expression error: Unexpected < operator.
- {{round|5555.5555|-2|down}} -> Expression error: Unexpected < operator.
- {{round|5555.5555|-3|down}} -> Expression error: Unexpected < operator.
- {{round|5555.5555|-4|down}} -> Expression error: Unexpected < operator.
- {{round|5555.5555|-4|up}} -> Expression error: Unexpected < operator.
- {{round|5555.5555|-3|up}} -> Expression error: Unexpected < operator.
- {{round|5555.5555|-2|up}} -> Expression error: Unexpected < operator.
- {{round|5555.5555|-1|up}} -> Expression error: Unexpected < operator.
- {{round|5555.5555|1|up}} -> 5555.6
- {{round|5555.5555|2|up}} -> 5555.56
- {{round|5555.5555|3|up}} -> 5555.556
- {{round|5555.5555|4|up}} -> 5555.5556
This template can also be substituted to imprint the outcome on the page.