Шаблон:Iffloat
Зоҳир
Usage
Returns {{{2|1}}} if {{{1}}} is a floating point number and {{{3|0}}} otherwise (i.e. for integers and strings).
Examples
code | result |
---|---|
{{Iffloat|1}} |
0 |
{{Iffloat|1.0}} |
0 |
{{Iffloat|1.1}} |
1 |
{{Iffloat|1|a float|not a float}} |
not a float |
{{Iffloat|1.0|a float|not a float}} |
not a float |
{{Iffloat|1.1|a float|not a float}} |
a float |
{{Iffloat|1/2|a float|not a float}} |
a float |
{{Iffloat|1/1|a float|not a float}} |
not a float |
{{Iffloat|1e3|a float|not a float}} |
not a float |
{{Iffloat|1e-3|a float|not a float}} |
a float |
{{Iffloat|0.1e3|a float|not a float}} |
not a float |
Notes
This template will not recognize formatted numbers, which is by design since formatted numbers will break expression parsers. To remove the formatting from a number, you can wrap the number first in {{formatnum: number |R}}.
code | result |
---|---|
{{Iffloat|1,000.50|a float|not a float}} | not a float |
{{Iffloat|{{formatnum:1,000.50|R}}|a float|not a float}} | a float |
See also
- {{ifnumber}}