diff options
author | David Robillard <d@drobilla.net> | 2019-10-06 20:40:56 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2020-10-27 13:13:59 +0100 |
commit | 9e59a63d9b5897d9ff6d0d9936a57c3167ea9a34 (patch) | |
tree | f54ecb581bef3e8476725e989b36e14ac556e0a2 /serd | |
parent | 5a0d9e5a66e0ad0b85db3740b479301128637ad5 (diff) | |
download | serd-9e59a63d9b5897d9ff6d0d9936a57c3167ea9a34.tar.gz serd-9e59a63d9b5897d9ff6d0d9936a57c3167ea9a34.tar.bz2 serd-9e59a63d9b5897d9ff6d0d9936a57c3167ea9a34.zip |
Add precise decimal digit generation
Diffstat (limited to 'serd')
-rw-r--r-- | serd/serd.h | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/serd/serd.h b/serd/serd.h index e76aaa44..9dbbffa0 100644 --- a/serd/serd.h +++ b/serd/serd.h @@ -705,16 +705,24 @@ serd_new_relative_uri(const char* str, will be written after the decimal point, but trailing zeros will automatically be omitted (except one if `d` is a round integer). - Note that about 16 and 8 fractional digits are required to precisely - represent a double and float, respectively. + Note that 17 and 9 significant digits are required to precisely represent + any double and float, respectively. This function may be lossy if + `precision` is too low, or if `frac_digits` is not 0 (unlimited). + + This function may produce very long strings, serd_new_float() or + serd_new_double() may be a better choice for very large or small numbers. @param d The value for the new node. - @param frac_digits The maximum number of digits after the decimal place. + @param max_precision Maximum number of significant decimal digits. + @param max_frac_digits Maximum number of digits after decimal point, or 0. @param datatype Datatype of node, or NULL for xsd:decimal. */ SERD_API SerdNode* -serd_new_decimal(double d, unsigned frac_digits, const SerdNode* datatype); +serd_new_decimal(double d, + unsigned max_precision, + unsigned max_frac_digits, + const SerdNode* datatype); /** Create a new node by serialising `i` into an xsd:integer string |