#why doesn't my rng generator work ?

19 messages · Page 1 of 1 (latest)

night totemBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

unkempt crane
#

What doesnt work?

bitter tide
patent lake
#

I think if you want something random, you should rather choose ways that are reasonable to the programme itself.

unkempt crane
#

Maybe the value in that memory location is zero or your compiler auto sets it to zero. Normally thats UB and you should use a different method

naive stratus
#

this is undefined behavior. the compiler simply can do as it please. you cannot relay on some indeterminate value to be random

bitter tide
#

o hmm i thought uninitialized variables are always random

patent lake
#

in your word, it should be unexpective rather than unpredictable

patent lake
#

and yes, maybe it seems to be random to YOUR programme, but it will cause more problems than what you would ever want

#

cons over pros

#

(i mean you could just take your CPU temperature as a part of seed calculating formula, that is, if you really want to do something with RNG

naive stratus
# bitter tide o hmm i thought uninitialized variables are always random

undefined behavior means the standard didn't associate any behavior for something. in practice this leaves things for the implementation. what actually may happen can vary. the compiler can insert some value there, can generate some code to load whatever in the stack at one point or crash the whole thing down. you cannot relay on it and shouldn't do so

patent lake
#

that's true. you cannot rely on it

bitter tide
#

thank you guys so much for the help !

#

!solved

night totemBOT
#

Thank you and let us know if you have any more questions!

This thread is now set to auto-hide after an hour of inactivity