aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/serd/serd.h32
1 files changed, 31 insertions, 1 deletions
diff --git a/include/serd/serd.h b/include/serd/serd.h
index fdae8ac7..e1a28fdf 100644
--- a/include/serd/serd.h
+++ b/include/serd/serd.h
@@ -627,7 +627,37 @@ SerdNode* SERD_ALLOCATED
serd_new_decimal(double d, const SerdNode* SERD_NULLABLE datatype);
/**
- Create a new node by serialising `i` into an xsd:integer string.
+ Create a new node by serialising `d` into a normalised xsd:double string.
+
+ The returned node will always be in normalised scientific notation, like
+ "1.23E4", except for NaN and negative/positive infinity, which are "NaN",
+ "-INF", and "INF", respectively.
+
+ Uses the shortest possible representation that precisely describes `d`,
+ which has at most 17 significant digits (under 24 characters total).
+
+ @param d Double value to serialise.
+ @return A literal node with datatype xsd:double.
+*/
+SERD_API
+SerdNode* SERD_ALLOCATED
+serd_new_double(double d);
+
+/**
+ Create a new node by serialising `f` into a normalised xsd:float string.
+
+ Uses identical formatting to serd_new_double(), except with at most 9
+ significant digits (under 14 characters total).
+
+ @param f Float value to serialise.
+ @return A literal node with datatype xsd:float.
+*/
+SERD_API
+SerdNode* SERD_ALLOCATED
+serd_new_float(float f);
+
+/**
+ Create a new node by serialising `i` into an xsd:integer string
@param i Integer value to serialise.
@param datatype Datatype of node, or NULL for xsd:integer.