MathGroup Archive 2001

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Is this a bug?

  • To: mathgroup at
  • Subject: [mg32069] Re: Is this a bug?
  • From: atelesforos at (Orestis Vantzos)
  • Date: Sat, 22 Dec 2001 04:22:40 -0500 (EST)
  • References: <9vs8ph$g1d$>
  • Sender: owner-wri-mathgroup at

Your problem is with a[Random[Integer{0,1}]]++ :
It is interpreted as a[Random[Integer{0,1}]]=a[Random[Integer{0,1}]]+1
and therefore some of the times the loop transfers the value of one
register to the other (plus 1). In that case the combined value can
drop or rise by more than 1 -- hence you do not have a total sum of
Mathematica is not C! Increment (++) has attribute HoldFirst,
therefore its argument (a[Random...] in this case) is evaluated ONLY
after arg++ has been replaced by arg=arg+1. Therefore this behaviour
is completely normal..

  • Prev by Date: Re: NDSolve problem with piecewise functions
  • Next by Date: Re: Replacement Rule
  • Previous by thread: Re: Is this a bug?
  • Next by thread: Re: Re: Is this a bug?