ambiguous ?

mcdonald at uxe.cso.uiuc.edu mcdonald at uxe.cso.uiuc.edu
Sun Oct 22 10:27:19 AEST 1989


>> 
>> 	I = RAND(very carefully designed seed)
>> 	CALL HOOPY(RAND(0), RAND(0), RAND(0))
>> 
>> Will this program produce the same output on different machines? Is this
>> guaranteed?

>The call to HOOPY is not standard conforming.  The relevant part of the
>standard is:

>      6.6.2 [...]
 >     In a statement that contains more than one function
 >     reference, the value provided by each function reference
 >     must be independent of the order chosen by the processor for
 >     evaluation of the function references.

That last paragraph doesn't seem to apply - if RAND(0) produces
truly random numbers (my best one really does - absolutely, truly
random, as best as I can tell. It digitizes noise.), then
the requirement in the standard is met.  Since the value of each function
reference is independent of everything, it is independent of the
order of calling it! Of course, if you use a FAKE rundom number 
generator - well, that is an interesting question. IF it is a really
good one, the program should still give "correct" answers. 
Of course if you don't REALLY want randomness, then the fragemnt is
clearly non-conforming.

Doug McDonald



More information about the Comp.lang.c mailing list