Template:IsNumeric

From Open Energy Information

This is the 'isNumeric' template. It combines a series of mediawiki hacks and work-arounds to determine if the supplied string is a number. This template will output either a 1 or a 0, and is intended for use with Parser Functions such as {{#if: .. }} or {{#expr: .. }} to perform logical or mathematical operations.

Parameters
  1. str - The string to be tested.


Usage

It should be called in the following format:

{{IsNumeric|42}}


Examples & Logical Tests

This template will produce the following results:

{{IsNumeric|42}} -> 1

{{IsNumeric|2,112}} -> 1

{{IsNumeric|13°C}} -> 0

{{IsNumeric|0.66}} -> 1

{{IsNumeric|three}} -> 0

{{IsNumeric| }} -> 0


Edit the page to see the template text.