From 8a277aa95a1e10e4651b08e0483eaabb2c426601 Mon Sep 17 00:00:00 2001 From: Abdulaziz Ghuloum Date: Mon, 8 Dec 2008 06:41:39 -0500 Subject: [PATCH] fixed parsing of complex numbers in the form +/-i where the is in scientific notation. --- scheme/ikarus.string-to-number.ss | 6 +++++- scheme/last-revision | 2 +- scheme/tests/string-to-number.ss | 3 +++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/scheme/ikarus.string-to-number.ss b/scheme/ikarus.string-to-number.ss index 1ba9ec9..383b508 100755 --- a/scheme/ikarus.string-to-number.ss +++ b/scheme/ikarus.string-to-number.ss @@ -170,7 +170,11 @@ (let ([mag (do-dec-sn/ex sn ex (* ac (expt 10 (+ exp1 (* exp2 exp-sign)))))]) (next polar r mag ex))] [(digit r) => d - (next exponent+digit r ex sn ac exp1 (+ (* exp2 r) d) exp-sign)]) + (next exponent+digit r ex sn ac exp1 (+ (* exp2 r) d) exp-sign)] + [(#\i) + (let ([n (do-dec-sn/ex sn ex + (* ac (expt 10 (+ exp1 (* exp2 exp-sign)))))]) + (next im:done (make-rectangular 0 n)))]) (polar (r mag ex) [(digit r) => d diff --git a/scheme/last-revision b/scheme/last-revision index 881a69e..859a8b2 100644 --- a/scheme/last-revision +++ b/scheme/last-revision @@ -1 +1 @@ -1705 +1706 diff --git a/scheme/tests/string-to-number.ss b/scheme/tests/string-to-number.ss index 3e3b757..c4fa8f1 100644 --- a/scheme/tests/string-to-number.ss +++ b/scheme/tests/string-to-number.ss @@ -244,6 +244,9 @@ (test "-0.i" (make-rectangular 0.0 -0.0)) (test "#d#e-0.0f-0-.0s-0i" 0) + (test "+.234e4i" (make-rectangular 0 0.234e4)) + (test "+.234e-5i" (make-rectangular 0 0.234e-5)) + (test "+.234i" (make-rectangular 0 0.234)) ) )