# `RDF.XSD.Numeric`
[🔗](https://github.com/rdf-elixir/rdf-ex/blob/v3.0.1/lib/rdf/xsd/datatypes/numeric.ex#L1)

Collection of functions for numeric literals.

# `t`

```elixir
@type t() :: module()
```

# `abs`

Returns the absolute value of a numeric literal.

If the given argument is not a numeric literal or a value which
can be coerced into a numeric literal, `nil` is returned.

see <http://www.w3.org/TR/xpath-functions/#func-abs>

# `add`

Adds two numeric literals.

For `xsd:float` or `xsd:double` values, if one of the operands is a zero or a
finite number and the other is INF or -INF, INF or -INF is returned. If both
operands are INF, INF is returned. If both operands are -INF, -INF is returned.
If one of the operands is INF and the other is -INF, NaN is returned.

If one of the given arguments is not a numeric literal or a value which
can be coerced into a numeric literal, `nil` is returned.

see <http://www.w3.org/TR/xpath-functions/#func-numeric-add>

# `ceil`

Rounds a numeric literal upwards to a whole number literal.

If the given argument is not a numeric literal or a value which
can be coerced into a numeric literal, `nil` is returned.

see <http://www.w3.org/TR/xpath-functions/#func-ceil>

# `datatype?`

# `divide`

Divides two numeric literals.

For `xsd:float` and `xsd:double` operands, floating point division is performed
as specified in [IEEE 754-2008]. A positive number divided by positive zero
returns INF. A negative number divided by positive zero returns -INF. Division
by negative zero returns -INF and INF, respectively. Positive or negative zero
divided by positive or negative zero returns NaN. Also, INF or -INF divided by
INF or -INF returns NaN.

If one of the given arguments is not a numeric literal or a value which
can be coerced into a numeric literal, `nil` is returned.

`nil` is also returned for `xsd:decimal` and `xsd:integer` operands, if the
divisor is (positive or negative) zero.

see <http://www.w3.org/TR/xpath-functions/#func-numeric-divide>

# `equal_value?`

Tests for numeric value equality of two numeric XSD datatyped literals.

see:

- <https://www.w3.org/TR/sparql11-query/#OperatorMapping>
- <https://www.w3.org/TR/xpath-functions/#func-numeric-equal>

## Examples

    iex> RDF.XSD.Numeric.equal_value?(RDF.XSD.integer(1), RDF.XSD.decimal("1.0"))
    true

# `floor`

Rounds a numeric literal downwards to a whole number literal.

If the given argument is not a numeric literal or a value which
can be coerced into a numeric literal, `nil` is returned.

see <http://www.w3.org/TR/xpath-functions/#func-floor>

# `multiply`

Multiplies two numeric literals.

For `xsd:float` or `xsd:double` values, if one of the operands is a zero and
the other is an infinity, NaN is returned. If one of the operands is a non-zero
number and the other is an infinity, an infinity with the appropriate sign is
returned.

If one of the given arguments is not a numeric literal or a value which
can be coerced into a numeric literal, `nil` is returned.

see <http://www.w3.org/TR/xpath-functions/#func-numeric-multiply>

# `negative_zero?`

```elixir
@spec negative_zero?(any()) :: boolean()
```

# `round`

Rounds a value to a specified number of decimal places, rounding upwards if two such values are equally near.

The function returns the nearest (that is, numerically closest) value to the
given literal value that is a multiple of ten to the power of minus `precision`.
If two such values are equally near (for example, if the fractional part in the
literal value is exactly .5), the function returns the one that is closest to
positive infinity.

If the given argument is not a numeric literal or a value which
can be coerced into a numeric literal, `nil` is returned.

see <http://www.w3.org/TR/xpath-functions/#func-round>

# `subtract`

Subtracts two numeric literals.

For `xsd:float` or `xsd:double` values, if one of the operands is a zero or a
finite number and the other is INF or -INF, an infinity of the appropriate sign
is returned. If both operands are INF or -INF, NaN is returned. If one of the
operands is INF and the other is -INF, an infinity of the appropriate sign is
returned.

If one of the given arguments is not a numeric literal or a value which
can be coerced into a numeric literal, `nil` is returned.

see <http://www.w3.org/TR/xpath-functions/#func-numeric-subtract>

# `zero?`

```elixir
@spec zero?(any()) :: boolean()
```

---

*Consult [api-reference.md](api-reference.md) for complete listing*
