diff options
author | Marius Vollmer <mvo@zagadka.de> | 2004-10-22 13:50:39 +0000 |
---|---|---|
committer | Marius Vollmer <mvo@zagadka.de> | 2004-10-22 13:50:39 +0000 |
commit | 2881e77b5a00d8fa397b5c302dd60afd2de49d2d (patch) | |
tree | acfbdfb7b85002e075e561375bb3dfb3dbd5b0e8 /libguile/numbers.c | |
parent | 77c2594f2f88fc8c2ec79126c9f04c9eb8b2d057 (diff) | |
download | guile-2881e77b5a00d8fa397b5c302dd60afd2de49d2d.tar.gz |
(SCM_T_INTBUFLEN): Increased to cover
scm_t_intmax values.
(scm_uint2str): New, for scm_t_uintmax.
(scm_iint2str): Argument type changed to scm_t_intmax,
reimplemented in terms of scm_uint2str.
Diffstat (limited to 'libguile/numbers.c')
-rw-r--r-- | libguile/numbers.c | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/libguile/numbers.c b/libguile/numbers.c index 8b83f786a..dde66457f 100644 --- a/libguile/numbers.c +++ b/libguile/numbers.c @@ -2218,29 +2218,38 @@ iflo2str (SCM flt, char *str, int radix) return i; } -/* convert a long to a string (unterminated). returns the number of +/* convert a scm_t_intmax to a string (unterminated). returns the number of characters in the result. rad is output base p is destination: worst case (base 2) is SCM_INTBUFLEN */ size_t -scm_iint2str (long num, int rad, char *p) +scm_iint2str (scm_t_intmax num, int rad, char *p) +{ + if (num < 0) + { + *p++ = '-'; + return scm_iuint2str (-num, rad, p) + 1; + } + else + return scm_iuint2str (num, rad, p); +} + +/* convert a scm_t_intmax to a string (unterminated). returns the number of + characters in the result. + rad is output base + p is destination: worst case (base 2) is SCM_INTBUFLEN */ +size_t +scm_iuint2str (scm_t_uintmax num, int rad, char *p) { size_t j = 1; size_t i; - unsigned long n = (num < 0) ? -num : num; + scm_t_uintmax n = num; for (n /= rad; n > 0; n /= rad) j++; i = j; - if (num < 0) - { - *p++ = '-'; - j++; - n = -num; - } - else - n = num; + n = num; while (i--) { int d = n % rad; |