aboutsummaryrefslogtreecommitdiffstats
path: root/src/decimal.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/decimal.h')
-rw-r--r--src/decimal.h20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/decimal.h b/src/decimal.h
index eefc07ef..8575cd85 100644
--- a/src/decimal.h
+++ b/src/decimal.h
@@ -19,14 +19,26 @@
#include <stdint.h>
+typedef struct {
+ unsigned count; ///< Number of digits
+ int expt; ///< Power of 10 exponent
+} SerdDecimalCount;
+
/// Return the number of decimal digits required to represent `n`
int
serd_count_digits(uint64_t i);
-unsigned
-serd_double_int_digits(double abs);
+/**
+ Write significant decimal digits for `d` into `buf`.
+
+ Writes only significant digits, without any leading or trailing zeros. The
+ actual number is given by the exponent in the return value.
-unsigned
-serd_decimals(double d, char* buf, unsigned frac_digits);
+ @param d The number to convert to decimal, must be finite and non-zero.
+ @param buf The output buffer at least `max_digits` long.
+ @param max_digits The maximum number of digits to write.
+*/
+SerdDecimalCount
+serd_decimals(double d, char* buf, unsigned max_digits);
#endif // SERD_DECIMAL_H