diff options
author | David Robillard <d@drobilla.net> | 2019-10-06 20:59:12 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2021-03-08 23:23:05 -0500 |
commit | 3bf35cb9e72709fb417cff0d5a2dc9b681e5ecb1 (patch) | |
tree | 722bf1099a386a048ea0419ae1be720c8da31eb0 /include/serd | |
parent | 8de05b1e2f7849e47c8ac82452a2e038664e510e (diff) | |
download | serd-3bf35cb9e72709fb417cff0d5a2dc9b681e5ecb1.tar.gz serd-3bf35cb9e72709fb417cff0d5a2dc9b681e5ecb1.tar.bz2 serd-3bf35cb9e72709fb417cff0d5a2dc9b681e5ecb1.zip |
Add serd_new_float() and serd_new_double()
Diffstat (limited to 'include/serd')
-rw-r--r-- | include/serd/serd.h | 32 |
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. |