Summary

number->string in numbers egg does not fail correctly

Metadata

Description

(number->string "7") -> #f (use numbers) (number->string "7" 3) -> 7

I will try to come up with a patch.

Changes and comments

[2010-04-04 22:59:36 UTC] felix set cc to sjamaan

[2010-04-04 22:59:36 UTC] felix removed milestone 4.5.0

[2010-04-05 10:38:23 UTC] ckeen wrote:

Replying to ckeen: > (number->string "7") -> #f > (use numbers) > (number->string "7" 3) -> 7

This of course is nonsense! Sorry for adding to the confusion.

The correct and still failing case is (string->number)

[2010-04-05 11:40:24 UTC] ckeen wrote:

When calling the core version base should be passed to it too:

Index: numbers.scm =================================================================== --- numbers.scm (revision 17731) +++ numbers.scm (working copy) @@ -1670,7 +1670,7 @@

                                               (if (and m (pair? (cdr m)) (pair? (cadr m)))
                                                   (fin (make-complex 0 (real sub (caadr m) (cadadr m))))
                                                   (fin (or (real str start len)

- (string->number-0 str) )) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) + (string->number-0 str base) )) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) )

[2010-04-05 11:53:01 UTC] ckeen wrote:

And here is a test case for it: Index: numbers-test.scm =================================================================== --- numbers-test.scm (revision 17731) +++ numbers-test.scm (working copy) @@ -447,6 +447,7 @@

 (test "fix" 123 (string->number "123"))
 (test "fix/base" 255 (string->number "ff" 16))
 (test "fix/base-o" 14 (string->number "16" 8))

+ (test "fix/wrong-base" #f (string->number "123" 3))

 (test "flo" 0.0 (string->number "#"))
 (test "flo" 123.23 (string->number "123.23"))
 (test "flo2" 100.23 (string->number "1##.23"))

[2010-04-05 12:46:03 UTC] sjamaan changed status from new to accepted

[2010-04-05 12:46:03 UTC] sjamaan set owner to sjamaan

[2010-04-05 12:46:03 UTC] sjamaan wrote:

Patches are applied (with a small change in the tests)

Thank you!

Please close the ticket if this is alright by you.

[2010-04-05 13:28:25 UTC] ckeen set resolution to fixed

[2010-04-05 13:28:25 UTC] ckeen changed status from accepted to closed