[Ns-developers] BUG in rng.cc ?
George Riley
riley at ece.gatech.edu
Fri Jun 9 01:07:04 PDT 2006
No, I disagree. The first "if(s)" checks for non-zero. If it is zero,
the else condition is used which sets the heuristic seed. If it is
not zero, the second "if(s <= 0)" checks for invalid.
I do agree that the second "if" is confusing, and should say:
"if (s < 0)" rather than "if (s <= 0)", since s cannot be zero here.
George
------------------------------------------------------------------------
--------------------
Dr. George F. Riley, Assistant Professor
The School of Electrical and Computer Engineering at Georgia Tech
Atlanta, GA 30332-0250
(404)-894-4767
E-Mail: riley at ece.gatech.edu
ECE3090 Web Page: http://users.ece.gatech.edu/~riley/ece3090/
ECE2040 Web Page: http://users.ece.gatech.edu/~riley/ece2040/
On Jun 8, 2006, at 11:24 AM, Julien HELMER wrote:
> Hello,
>
> In the context of my work with NS-2 I was looking at the source code
> of RNG
> model, and in rng.cc I saw this:
>
> (We are at line 239 of rng.cc, in the command() method ; s being the
> seed
> specified in TCL)
>
> *if (s) {
> * if (*s <= 0* || (unsigned int)s >= MAXINT) {
> tcl.resultf("Setting random number seed to known bad value.");
> return TCL_ERROR;
> };
> set_seed(RAW_SEED_SOURCE, s);
> } else set_seed(HEURISTIC_SEED_SOURCE, 0);
>
> (Ended at line 245)
>
> So, in this code, I think that the test "if (s)" - which means if
> (s!=NULL)
> - is dummy because it prevents to check if s==0 in fact. In the case
> s==0,
> with this code we set the seed as if it was correct whereas this
> value should be considered as a "known bad value".
>
> Hope you see the issue,
>
> Best Regards,
> Julien
More information about the Ns-developers
mailing list