This site is supported by donations to The OEIS Foundation.

Template:Abs

From OeisWiki

Jump to: navigation, search
The following documentation is located at Template:Abs/doc. [Edit Template:Abs/doc]
[<Purge> Template:Abs]

The {{abs}} mathematical function template returns the absolute value of a real number, otherwise returns an error message.

Contents

Usage

{{abs|a real number}}

You may also use the abs operator in a mathematical expression for a numerical argument of a template, e.g.

{{expr|abs a_real_number}}

or in a mathematical expression for a numerical argument of a parser function, e.g.

{{#expr: abs a_real_number }}

Valid input

An unformatted real number. (Cf. Formatted numbers)

Examples

Examples with valid input

Code Result Comment
{{abs|6}} 6
{{abs|6.5}} 6.5
{{abs|0}} 0
{{abs|-6.5e+45}} 6.5E+45
{{abs|-6E-12}} 6.0E-12
{{abs|{{formatnum: 6,500|R}}}} 6500 (Cf. Formatted numbers)

Examples with invalid input (returns error message)

Code Result Comment
{{abs|6,500}} Abs error: Argument is not a real number (Cf. Formatted numbers)
{{abs}} Abs error: Argument is not a real number
{{abs|i}} Abs error: Argument is not a real number
{{abs|blob}} Abs error: Argument is not a real number
{{abs|6 blobs}} Abs error: Argument is not a real number

Code


{{ifnum| {{{1|NAN}}} 
| {{#expr: abs ({{{1}}}) }} 
| {{error|Abs error: Argument is not a real number }} 
}}

See also

  • {{abs}} (or the abs operator) to obtain the absolute value of a real number
  • {{sgn}} (note that the sgn operator is not supported) to obtain the sign of a real number
Personal tools