diff options
author | David Robillard <d@drobilla.net> | 2019-10-06 20:59:12 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2020-10-27 13:13:59 +0100 |
commit | b24672bb03c30f5cb73f628362a97bb1b02d6818 (patch) | |
tree | d51d60801b2d5951cec150fe5990c72337b4aa37 /serd/serd.h | |
parent | 9e59a63d9b5897d9ff6d0d9936a57c3167ea9a34 (diff) | |
download | serd-b24672bb03c30f5cb73f628362a97bb1b02d6818.tar.gz serd-b24672bb03c30f5cb73f628362a97bb1b02d6818.tar.bz2 serd-b24672bb03c30f5cb73f628362a97bb1b02d6818.zip |
Add support for xsd:double and xsd:float
These can be used to serialise a float or double in the shortest normalised
form that can be read back in to the exact same floating point value.
Diffstat (limited to 'serd/serd.h')
-rw-r--r-- | serd/serd.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/serd/serd.h b/serd/serd.h index 9dbbffa0..5a6815f8 100644 --- a/serd/serd.h +++ b/serd/serd.h @@ -725,6 +725,36 @@ serd_new_decimal(double d, const SerdNode* datatype); /** + 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_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_new_float(float f); + +/** Create a new node by serialising `i` into an xsd:integer string @param i Integer value to serialise. |