Board Thread:Support Requests - Getting Technical/@comment-1333593-20201004204045

Hi!

I'm looking for a solution to an issue that popped up after the UCP migration. We're using infoicon-style templates that also highlight the text passed to them to display after the icon. Previously, we were able to use #iferror on formatnum to tell whether a parameter was a number or not, and then use formatnum to add thousands separators to it if it is.

However, after the migration, formatnum no longer returns an error. Instead, it returns 0 for most text, which means we get that as the output. At first, I thought, okay, I'll just check for a zero parameter with #ifeq first, and if that's false, then a zero return from formatnum must be text. But unfortunately, the issue seems to be more complicated than that. If the parameter is a string that starts with a number (e.g. "0.5 Movement Points"), then I get a non-zero number return (in this case, "1"), which is completely wrong regardless of which way I'm looking at it.

So my question is, can formatnum be told to return an error instead if the entire parameter can't be interpreted as a number? Alternatively, is there a different way to tell a number value apart from a string value?

Then there's also the issue of rounding. I can't see anything in the Mediawiki help on the formatnum magic word that would indicate that it rounds by default. Is there some kind of switch to turn off this behaviour?

An example of the template that worked before the migration: https://masterofmagic.fandom.com/wiki/Template:Production 