This template rounds up a numeric value to a limited number of decimal places.
- Usage:
- {{Roundup|value}}
- {{Roundup|value|decimals}}
- Both parameters can be any valid numeric expression.
- The decimals parameter defaults to 0 and is rounded to the nearest integer.
- decimals can be negative to round up to a multiple of a power of ten.
- If decimals is not between -20 and 20, the value is returned without rounding.
- Examples:
- {{Roundup|3.14159|3}} = {{expr:{{ifexpr: 3.14159-(3.14159 round 3)<=0|(3.14159) round 3|((3.14159) round 3) + (3.14159)/3.14159/1000}}}}
- {{Roundup|0|3}} = {{expr:{{ifexpr: 0-(0 round 3)<=0|(0) round 3|((0) round 3) + (0)/0/1000}}}} (should be 0, not 0.001)
- {{Roundup|-0.00031|3}} = {{expr:{{ifexpr: 0.00031-(0.00031 round 3)<=0|(-0.00031) round 3|((-0.00031) round 3) + (-0.00031)/0.00031/1000}}}} (should be -0.001, not 0)
- {{Roundup|-3.14159|3}} = {{expr:{{ifexpr: 3.14159-(3.14159 round 3)<=0|(-3.14159) round 3|((-3.14159) round 3) + (-3.14159)/3.14159/1000}}}}
- {{Roundup|0|0}} = {{expr:{{ifexpr: 0-(0 round 0)<=0|(0) round 0|((0) round 0) + (0)/0/1}}}} (should be 0, not 1)
- {{Roundup|-0.9|0}} = {{expr:{{ifexpr: 0.9-(0.9 round 0)<=0|(-0.9) round 0|((-0.9) round 0) + (-0.9)/0.9/1}}}} (should be -1, not 0)
- {{Roundup|314159|-3}} = {{expr:{{ifexpr: 314159-(314159 round -3)<=0|(314159) round -3|((314159) round -3) + (314159)/314159/0.001}}}}
- {{Roundup|0|-3}} = {{expr:{{ifexpr: 0-(0 round -3)<=0|(0) round -3|((0) round -3) + (0)/0/0.001}}}} (should be 0, not 1000)
- {{Roundup|-514.15|-3}} = {{expr:{{ifexpr: 514.15-(514.15 round -3)<=0|(-514.15) round -3|((-514.15) round -3) + (-514.15)/514.15/0.001}}}} (should be -1000, not 0)
- {{Roundup|-514159|-3}} = {{expr:{{ifexpr: 514159-(514159 round -3)<=0|(-514159) round -3|((-514159) round -3) + (-514159)/514159/0.001}}}}
- Note:
- {{Ceil|value}} is equivalent to {{Roundup|value}}.
- See also: