Opened 14 years ago

Closed 14 years ago

#205 closed enhancement (fixed)

number->string does not accept abritrary radixes

Reported by: Christian Kellermann Owned by:
Priority: not urgent at all Milestone: 4.5.0
Component: unknown Version: 4.4.x
Keywords: Cc:
Estimated difficulty:

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!

Attachments (1)

number-to-string.diff (2.2 KB) - added by Christian Kellermann 14 years ago.

Download all attachments as: .zip

Change History (3)

Changed 14 years ago by Christian Kellermann

Attachment: number-to-string.diff added

comment:1 Changed 14 years ago by Christian Kellermann

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")

comment:2 Changed 14 years ago by felix winkelmann

Resolution: fixed
Status: newclosed

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

Note: See TracTickets for help on using tickets.