User:KadaneBot/Task2/ReplacementRules
Appearance
- Let NAME be the name of the template
- Let NUMBER represent the number to be rounded (first parameter)
- Let PLACE represent the number of places to round to (second parameter)
- If NUMBER is not defined log an invalid template to User:KadaneBot/ErrorLog
- If NAME is Round and PLACE is undefined and NUMBER has 1 decimal place:
- Change NAME to Rnd
- Change PLACE to 1
- IF NAME is Round and PLACE is undefined and NUMBER has 2 decimal places:
- Change NAME to Rnd
- Change PLACE to 2
- IF NAME is Round and PLACE is undefined and NUMBER has 3 or more decimal places:
- Change NAME to Rnd
- Change PLACE to 3
- IF NAME is Round and PLACE is undefined and NUMBER is a wiki markup expression:
- Change NAME to Rnd
- Change PLACE to 3
Note: This can result in a change of appearance, but does not result in loss of precision
- IF NAME is Round or NAME is Decimals and PLACE is not an integer:
- Cast Place to an integer and save