bobes Posted August 10, 2014 Posted August 10, 2014 When I am entering vaules to my float variables some of them are returning wrong huge numers. For example I entered 0 and it returned 916455424. Please can anybody tell me the reason or solution?
Strange Posted August 10, 2014 Posted August 10, 2014 Without knowing more about what you are doing (you don't even say what language you are using) it is impossible to say. Can you post a simple example?
Sensei Posted August 10, 2014 Posted August 10, 2014 If you would have f.e. array overflow on stack or structure, you would be reading wrong values in data prior, or after field that has overflow. f.e. struct X { float data1; char data2[ 10 ]; float data3; }; X x; x.data2[ -1 ] = 123; // array entry at index -1 is in reality data1 x.data2[ 10 ] = 456; // array entry at index 10 is in reality data3 It happens more often than you think- typically index to array is dynamic, not static like in example above. So there might happen some bug causing reading/writing from negative index, and reading/writing wrong value from/to wrong place.
Strange Posted August 10, 2014 Posted August 10, 2014 And if it is array data in C, then bobes may be accidentally printing the address of a variable instead of the content. Or it could be an uninitialised variable. Or a local variable being accessed out of scope so it has been overwritten. Or ...
Unity+ Posted August 13, 2014 Posted August 13, 2014 Or it could be an uninitialised variable. that usually ends up with an error or null.
timo Posted August 13, 2014 Posted August 13, 2014 that usually ends up with an error or null. Unless he OP usually uses a different programming language than you usually do. Out of curiousity: In which programming languages does no initializing a basic float value end up with an error or null?
Unity+ Posted August 16, 2014 Posted August 16, 2014 (edited) Unless he OP usually uses a different programming language than you usually do. Out of curiousity: In which programming languages does no initializing a basic float value end up with an error or null? I think a majority of languages do. You have to initialize the variable in the first place in order to use it, I would think. And the language the OP is using is either C or C++. I could be wrong. int t; int t = 0; I could be interpreting the statement wrong, though. Edited August 16, 2014 by Unity+
Unity+ Posted August 16, 2014 Posted August 16, 2014 I guess we will never know ... Unless the OP comes back, I think this thread is dead.
Vasanth M S Posted October 29, 2014 Posted October 29, 2014 Maybe you are using the same variable again and again. For Exmaple : sum=sum+i; Now here if sum is not declared as int sum=0; then junk value of sum will be printed instead of the actual value. Try print an integer variable without assigning any value to it ; you will get some junk value printed. I guess this maybe your problem.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now