# View Source RDF.XSD.Numeric(RDF.ex v1.1.1)

Collection of functions for numeric literals.

# Link to this section Summary

## Functions

Returns the absolute value of a numeric literal.

Rounds a numeric literal upwards to a whole number literal.

See `RDF.Literal.Datatype.Registry.numeric_datatype?/1`.

Divides two numeric literals.

Rounds a numeric literal downwards to a whole number literal.

Multiplies two numeric literals.

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

Subtracts two numeric literals.

# t()

View Source
`@type t() :: module()`

# abs(literal)

View Source

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.

View Source

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.

# ceil(literal)

View Source

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.

# datatype?(value)

View Source

See `RDF.Literal.Datatype.Registry.numeric_datatype?/1`.

# divide(arg1, arg2)

View Source

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.

# floor(literal)

View Source

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.

# multiply(arg1, arg2)

View Source

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.

# negative_zero?(arg1)

View Source
`@spec negative_zero?(any()) :: boolean()`

# round(literal, precision \\ 0)

View Source

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.

# subtract(arg1, arg2)

View Source

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.

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