LiteralTerm.decimal constructor
- double value
Create a decimal literal
This is a convenience factory for creating literals with xsd:decimal datatype. Decimal literals in RDF represent numeric values that can have fractional parts.
Parameters:
value
The double value to encode as a decimal literal
Returns: A new LiteralTerm with value converted to string and datatype set to xsd:decimal
Note: Be aware that floating-point representation may lead to precision issues in some cases. For exact decimal representation, consider converting the value to a string with the desired precision before creating the literal.
Example:
// Create a decimal literal
final decimalLiteral = LiteralTerm.decimal(3.14);
// Equivalent to manually creating a typed literal
final manualDecimal = LiteralTerm("3.14", datatype: Xsd.decimal);
Implementation
factory LiteralTerm.decimal(double value) {
return LiteralTerm(value.toString(), datatype: Xsd.decimal);
}