Random number generator

Zeekater

hasn't been using drugs
Joined
May 27, 2003
Messages
2,245
Location
Belgium
Could someone help me find the function that the delphi program uses to create a random number?

When using 2 programs written in different languages, they both use different random number generators.

Thx for any help :)
 
Thx for that.

Had already seen it though, it doesn't give the exact way how delphi computes random numbers. :)
 
"When using 2 programs written in different languages, they both use different random number generators."


Say you want to use a program written in Java in a program written in Delphi. They both use random number generators for a same thing, but the outcome is different, and they should be the same.
 
Yaroslav, thx for all the feedback, greatly appreciated :).

It's not quite what I'm looking for though, had already googled it, but didn't find anything.

I'm looking for someone who knows, or knows where to find it (on the net or in delphi self) :)
 
Normally there's a "Random" function on Microsoft Excel. I don't remember well but I think you should type :

=RANDOM()

And it will give you a random number.
 
Is their such thing as a true Random Number Generator? I was under the impressxion that it was impossible to get a truly random number to be generated, that there is always a pattern that develops.
 
Originally posted by EmpireofVirtue
Normally there's a "Random" function on Microsoft Excel. I don't remember well but I think you should type :

=RANDOM()

And it will give you a random number.

The Excell function is pretty lousy, with volatile vars and all. But you can make a separate program, then manipulate it with controllers (int main (int argc, char *argv ) {...}
 
Originally posted by RealGoober
Is their such thing as a true Random Number Generator? I was under the impressxion that it was impossible to get a truly random number to be generated, that there is always a pattern that develops.
Try pi. that's quite random.

However, you are right, the only way to get true randomness is by measuring quantum effects, as would be possible with quantum commputing. A normal computer cannot do this.
 
I'm not looking for 'real' random numbers, random doesn't exist. :)

'Random' is computed by taking a number, like the time, and then use it in some sort of function. It is that precise function I'm looking for from Delphi :)
 
Zeekater, I don't own delphi, however I'm pretty sure that you can find the function code in Delphi itself.... :D

Have you installed Delphi sources? Have you tried to do a search with text "random" in Delphi subfolders?
 
that's one thing i haven't tried yet, was hoping not to have to do it though :)

i'll see if i can find something in java, if i can't find it there, i most likely won't be able to find in delphi either.

it might be something that you can't bring up so easily :)
 
i'll see if i can find something in java, if i can't find it there, i most likely won't be able to find in delphi either.

Look at the API docs of java.util.Random class. That's not the best random number generator, but if you're only doing games or such, it'll serve you well - it's very easy to use.

If you need better random numbers, use java.security.SecureRandom class. It's slower, but much better.

There're also tons of RNG code out there... just Google search for them.


Also while I haven't touched Delphi in ages (my only exp. with Delphi is Delphi 3), I find it impossible that there's no random functions in the core packages. Have you really looked at Delphi's doc?
 
kcwong, if I understand Zeekater correctly, he wants to know the internal algortihm used, not the name of the function and its parameters....
 
At work a couple of nights ago I was wondering:

could you have a program that divides for the value of pi, and then saves it's progress every time it is "turned off", to spit out a new number the next time it "turns on". To me this would either generate a random number, or find the true value of pi.
 
Neomega said:
At work a couple of nights ago I was wondering:

could you have a program that divides for the value of pi, and then saves it's progress every time it is "turned off", to spit out a new number the next time it "turns on". To me this would either generate a random number, or find the true value of pi.
Unfortunately, you need very specialised programming. 'Normal' programming data types simply can't hold enough decimal places.

PI has been calculated to millions of decimal places though....
 
Why is the clock RNG not sufficient? No-one can really time a second to the 1/1000th of a second anyway.
 
Back
Top Bottom