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.
19 messages · Page 1 of 1 (latest)
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.
What doesnt work?
the uninitialized value should be a garbage value and random but i keep getting 0 which is even and always that instead of a random value
I think if you want something random, you should rather choose ways that are reasonable to the programme itself.
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
this is undefined behavior. the compiler simply can do as it please. you cannot relay on some indeterminate value to be random
o hmm i thought uninitialized variables are always random
in your word, it should be unexpective rather than unpredictable
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
Oo right
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
ah i see
that's true. you cannot rely on it
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