Re: random() function produces wrong range
От | Malcolm Beattie |
---|---|
Тема | Re: random() function produces wrong range |
Дата | |
Msg-id | 20000803162756.B715@sable.ox.ac.uk обсуждение исходный текст |
Ответ на | Re: random() function produces wrong range (Tom Lane <tgl@sss.pgh.pa.us>) |
Список | pgsql-hackers |
Tom Lane writes: > I thought about that last night. We could do a configure test. Since > it'd be probing random() results there'd be a small probability of > failure, but if we wire in an assumption that the max value must be > 2^(15 + n*16)-1 for some n, ten or so probes would give us a failure > probability on the order of 2^-160, which ought to satisfy anyone. > > However, in the absence of any hard evidence that there are platforms > where the value is different from 2^31-1, it's probably just a waste of > configuration cycles at the moment. > > I suggest we add a config.h constant like > > /* The local random() function yields values 0 .. MAX_RANDOM_VALUE */ > #define MAX_RANDOM_VALUE <2^31-1> > > and use that in the code. Then, if we ever find a platform where > random() does actually produce 64-bit results, it'll be time enough > to crank up a real configure test to set the value. > > Comments? If any platform *does* produced 64-bit results, it won't be compliant with SUSv2 which states explicitly that the resulting range is up to 2^31-1. Since most portability problems are with older platforms which haven't caught up, I'd be hopeful that any new 64-bit-int platforms would get it right from the outset. Maybe I'm being over-optimistic :-) --Malcolm -- Malcolm Beattie <mbeattie@sable.ox.ac.uk> I am looking for a Linux (and Unix Systems Programmer maybe Apache/mod_perl) job/contract Oxford University Computing Services http://users.ox.ac.uk/~mbeattie/cv.html
В списке pgsql-hackers по дате отправления: