reader fails on some complex numbers

Bug #248631 reported by leppie
2
Affects Status Importance Assigned to Milestone
Ikarus Scheme
Fix Committed
Medium
Abdulaziz Ghuloum

Bug Description

Ikarus Scheme version 0.0.3+ (revision 1538, build 2008-07-15)
Copyright (c) 2006-2008 Abdulaziz Ghuloum

> 8+6.0i
Unhandled exception
 Condition components:
   1. &lexical
   2. &message: "invalid numeric sequence"
   3. &irritants: ("8+6.")
   4. &lexical-position:
       file-name: *stdin*
       character: 3
> 8.0+6i
8.0+6.0i
>

Related branches

Revision history for this message
leppie (leppie) wrote :

-6.0i works though.

Revision history for this message
leppie (leppie) wrote :

Some more:

> 8.0@6.0
Unhandled exception
 Condition components:
   1. &lexical
   2. &message: "invalid numeric sequence"
   3. &irritants: ("8.0@")
   4. &lexical-position:
       file-name: *stdin*
       character: 63
> 8@6
Unhandled exception
 Condition components:
   1. &lexical
   2. &message: "invalid numeric sequence"
   3. &irritants: ("8@")
   4. &lexical-position:
       file-name: *stdin*
       character: 69

Revision history for this message
leppie (leppie) wrote :

Some more:

> -0i
0
> Unhandled exception
 Condition components:
   1. &assertion
   2. &who: eval
   3. &message: "unbound variable"
   4. &irritants: (i)
>

Revision history for this message
leppie (leppie) wrote :

> +1i
+i
> Unhandled exception
 Condition components:
   1. &assertion
   2. &who: eval
   3. &message: "unbound variable"
   4. &irritants: (i)

Sorry im just pasting them all here :)

Revision history for this message
leppie (leppie) wrote :

> -0.i
0.0

Returns non-complex number, not sure what it should return however :-)

Revision history for this message
leppie (leppie) wrote :

Fails in nan.0 too:

> 8+nan.0i
Unhandled exception
 Condition components:
   1. &lexical
   2. &message: "invalid numeric sequence"
   3. &irritants: ("8+n")
   4. &lexical-position:
       file-name: *stdin*
       character: 149

Revision history for this message
leppie (leppie) wrote :

Another few:

> 8+6e20i
Unhandled exception
 Condition components:
   1. &lexical
   2. &message: "invalid numeric sequence"
   3. &irritants: ("8+6e")
   4. &lexical-position:
       file-name: *stdin*
       character: 3
> 8e10+6i
Unhandled exception
 Condition components:
   1. &lexical
   2. &message: "invalid numeric sequence"
   3. &irritants: ("8e10+")
   4. &lexical-position:
       file-name: *stdin*
       character: 12

Revision history for this message
leppie (leppie) wrote :

Yet another (sorry for all the individual ones, adding as I find it, hopefully it will provide useful for tests :-) ):

> +nan.0+i
Unhandled exception
 Condition components:
   1. &lexical
   2. &message: "invalid numeric sequence"
   3. &irritants: ("+nan.0+")
   4. &lexical-position:
       file-name: *stdin*
       character: 38

Revision history for this message
Abdulaziz Ghuloum (aghuloum) wrote : Re: [Bug 248631] Re: reader fails on some complex numbers

On Jul 15, 2008, at 8:35 AM, leppie wrote:

> Yet another (sorry for all the individual ones, adding as I find it,
> hopefully it will provide useful for tests :-) ):

It does. Thanks. Keep them coming. :-)

Revision history for this message
leppie (leppie) wrote :

Let's call it the night with this one :-)

> #d-0e-10-0e-0i
Unhandled exception
 Condition components:
   1. &lexical
   2. &message: "invalid numeric sequence"
   3. &irritants: ("#d-0e-10-")
   4. &lexical-position:
       file-name: *stdin*
       character: 8

Revision history for this message
leppie (leppie) wrote :

Ok here is the best I can come up with:

#d#e-0.0f-0-.0s-0i

Revision history for this message
Abdulaziz Ghuloum (aghuloum) wrote :

On Jul 15, 2008, at 3:26 AM, leppie wrote:

>> -0.i
> 0.0
>
> Returns non-complex number, not sure what it should return
> however :-)

Should be: 0.0-0.0i

Revision history for this message
Abdulaziz Ghuloum (aghuloum) wrote :

Fixed most of the problems in 1540. What remains are the 1f2, 1s2, and friends (I only have 1e2 for now) and the angular number syntax 1@2.

Changed in ikarus:
assignee: nobody → aghuloum
importance: Undecided → Medium
status: New → Confirmed
Revision history for this message
leppie (leppie) wrote :

> Fixed most of the problems in 1540.

Wow that was fast :)

Revision history for this message
leppie (leppie) wrote :

> Wow that was fast :)

And thanks to your speediness, I got the inspiration to implement it all for IronScheme too :) (just lacking mantissa width, and all exponent markers default to e).

Revision history for this message
leppie (leppie) wrote :

One of the tests are broken:

(test "#d-0e-10-0e-0i" (make-rectangular -0.0 -0.0))

should be

(test "#d-0e-10-0e-0i" (make-rectangular -0e-10 -0.0))

The idea was to test the 'minus' token :)

Revision history for this message
leppie (leppie) wrote :

Oops, sorry, my mistake! The test IS correct :)

Revision history for this message
leppie (leppie) wrote :

Is this correct?

#x+inf.0+nan.0i

My feeling is that this should not be allowed.

Assume this is valid, then it gets contradicted later in the spec with:

"If the representation of a number object has no exactness prefix, the constant is inexact if it contains a decimal point, an exponent, or a nonempty mantissa width; otherwise it is exact."[1]

But nan's and infinities are always inexact.

So it comes down to whether you count the decimal point inside +nan.0 and +inf.0 ...

Cheers

leppie

[1] http://www.r6rs.org/final/html/r6rs/r6rs-Z-H-2.html#node_toc_node_sec_4.2.8

Revision history for this message
leppie (leppie) wrote :

I rather raised this on the R6RS mailing list.

Revision history for this message
Abdulaziz Ghuloum (aghuloum) wrote :

I think this was fixed, right?

Changed in ikarus:
status: Confirmed → Fix Committed
Changed in ikarus:
milestone: none → 0.0.4
Revision history for this message
leppie (leppie) wrote :

Here is another one :)

> 0@-.0
Unhandled exception
 Condition components:
   1. &lexical
   2. &message: "invalid numeric sequence"
   3. &irritants: ("0@-")
   4. &source-position:
       file-name: *stdin*
       character: 384

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.