gnucobol-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [open-cobol-list] RANDOM-ly non-random


From: Bruce M. Axtens
Subject: Re: [open-cobol-list] RANDOM-ly non-random
Date: Fri, 31 May 2013 14:14:07 +0800
User-agent: Mozilla/5.0 (Windows NT 6.1; rv:22.0) Gecko/20100101 Thunderbird/22.0

On 31/05/2013 11:11 AM, address@hidden wrote:
Hello, Bruce

OpenCOBOL RANDOM returned biased value.

It is look like conacatinate '0.' and int(rand()*(2**32)) .

so, you execute this.

perl -e '$a = 0; for (1..1000) {$p = int(rand() * (2 ** 31)) ;$a +=
"0.".$p; }; print $a ;print "\n";'

it will show about 347 instead of 500.

Since it is wrong, we have to correct libcob.so.
It's times like these when one wishes that OpenCOBOL had for bugs what TeX has: <http://en.wikipedia.org/wiki/Knuth_reward_check>. It'd be nice to have in a frame on the wall an official looking certificate saying that I found a bug in OpenCOBOL.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]