Summary

number->string does not accept abritrary radixes

Metadata

Attachments

Description

The current implementation does not allow any other radix than the ones mentioned in R5RS (2,8,10,16). Whereas string->number does:

(use srfi-1) (map (lambda (n) (string->number "11" n)) (iota 15 2)) -> (3 4 5 6 7 8 9 10 11 12 13 14 15 16 17)

I think it is convenient if number->string supports at least arbitrary radix values form [[2,..,16]|].

The attached diff does exactly that. Since it is a general function that of course will also do binary, the patch removes the old binary function code.

Since this is my first patch I am completely unbiased and open for suggestions on coding style etc. Please keep the feedback comming!

Changes and comments

[2010-04-04 21:47:10 UTC] ckeen attached number-to-string.diff (description=#f)

[2010-04-04 21:49:07 UTC] ckeen wrote:

and of course with the above patch it does do as expected:

(map (lambda (n) (number->string 32 n)) (iota 15 2)) -> ("100000" "1012" "200" "112" "52" "44" "40" "35" "32" "2A" "28" "26" "24" "22" "20")

[2010-04-04 22:58:42 UTC] felix changed status from new to closed

[2010-04-04 22:58:42 UTC] felix set resolution to fixed

[2010-04-04 22:58:42 UTC] felix wrote:

Many thanks for the patch (the style is fine, btw). Applied in commit 14b2d48ca65a2e53af484ebd363a2c58b5dc8b0c (experimental).