Re: Strange machine-level exception

new topic     » goto parent     » topic index » view thread      » older message » newer message

Bernie Ryan wrote:

> Juergen Luethje wrote:
> > 
> > Bernie Ryan wrote:
> > 
> > <snip>
> > 
> > > Juergen:
> > >     Could the problem be caused by variations in the RAND() function ?
> > >     The rand() may be compiled different for each compiler or different
> > >     on each OS. The reason I say this is because the rand() occurs before
> > >     the line that is commented out.
> > > Bernie
> > 
> > I also had a similar suspicion. But now I found that the program still
> > crashes, when
> >    player = rand(3)
> > is replaced with
> >    player = remainder(i,3) + 1
> > 
> > }}}
<eucode>
> > function create_set (sequence s)
> >    -- create a set (= remove duplicate entries)
> >    integer p
> > 
> >    if length(s) < 2 then
> >       return s
> >    end if
> > 
> >    p = length(s)
> >    for i = length(s)-1 to 1 by -1 do
> >       if find_from(s[i], s, i+1) = 0 then  -- Machine-level exception here
> >          p -= 1
> >          s[p] = s[i]
> >       end if
> >    end for
> >    return s[p..$]
> > end function
> > 
> > 
> > sequence freq, result, unique
> > integer n, player
> > 
> > n = 1000
> > 
> > result = {}
> > for i = 1 to n do
> >    freq = repeat(0, 3)
> >    for card = 1 to 4 do
> > --       player = rand(3)           -- old
> >       player = remainder(i,3) + 1   -- new  -->  program still crashes
> >       freq[player] += 1
> >    end for
> >    result = append(result, freq)
> > end for
> > 
> > unique = create_set(result)
> > ? unique
> > if getc(0) then end if
> > </eucode>
{{{

> 
> Juergen:
> 
> I think the result of remainder can be a float and player is an integer 

I don't think that that is a problem, because the program does not crash
on the line:
   player = remainder(i,3) + 1

but as before, it crashes on the line:
   if find_from(s[i], s, i+1) = 0 then

Regards,
   Juergen

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu