View Source RDF.XSD.Numeric (RDF.ex v1.2.0)

Collection of functions for numeric literals.

Summary

Functions

Returns the absolute value of a numeric literal.

Adds two numeric literals.

Rounds a numeric literal upwards to a whole number literal.

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.

Types

Functions

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

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

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

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

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

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

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

@spec negative_zero?(any()) :: boolean()
Link to this function

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.

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

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

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