X-Git-Url: https://git.distorted.org.uk/~mdw/disorder/blobdiff_plain/460b9539a7c15580e41a71bbc0f47ae776238915..22168975d6ccc4b603ad2bfbb5ea3d3d43a21a5f:/lib/basen.c diff --git a/lib/basen.c b/lib/basen.c index 157919a..362ab58 100644 --- a/lib/basen.c +++ b/lib/basen.c @@ -25,7 +25,11 @@ #include "basen.h" -/* test whether v is 0 */ +/** @brief Test whether v is 0 + * @param v Pointer to bigendian bignum + * @param nwords Length of bignum + * @return !v + */ static int zero(const unsigned long *v, int nwords) { int n; @@ -34,7 +38,14 @@ static int zero(const unsigned long *v, int nwords) { return n == nwords; } -/* divide v by m returning the remainder */ +/** @brief Divide v by m returning the remainder. + * @param v Pointer to bigendian bignum + * @param nwords Length of bignum + * @param m Divisor (must not be 0) + * @return Remainder + * + * The quotient is stored in @p v. + */ static unsigned divide(unsigned long *v, int nwords, unsigned long m) { unsigned long r = 0, a, b; int n; @@ -54,6 +65,17 @@ static unsigned divide(unsigned long *v, int nwords, unsigned long m) { return r; } +/** @brief Convert v to a chosen base + * @param v Pointer to bigendian bignum + * @param nwords Length of bignum + * @param buffer Output buffer + * @param bufsize Size of output buffer + * @param base Number base (2..62) + * @return 0 on success, -1 if the buffer is too small + * + * Converts @p v to a string in the given base using decimal digits, lower case + * letter sand upper case letters as digits. + */ int basen(unsigned long *v, int nwords, char buffer[], @@ -78,4 +100,3 @@ comment-column:40 fill-column:79 End: */ -/* arch-tag:iGDXjhkM2cdyv0RSlftgGQ */