Whenever you create a local variable for a function, it is allocated in a memory area called "the stack". It contains the local variables and some more information that allows the computer to know when a function finishes executing, at what point in the previous function it has to return, and so on, until it reaches main()
.
One feature of this stack is that if a function is invoked, it uses some of that memory to hold its local functions. After that function returns, the memory it used is released, and if the code calling that function calls another function, it uses the same memory space that the first function used to store the variables locations. What's more, she does not worry about zeroing this region of memory or even allocating space before releasing it again.
The result of all this is that the value you encounter in an uninitialized local variable will depend on what functions were previously run in that program and how they ended up executing them. In other words, and borrowing C-terminology, when you read the value of an uninitialized local variable, the behavior is undefined . That is, any value can be there. In your case, it has been one; could be -1.357.928, too.
What is the lesson learned? Always initialize your local variables when declaring them . It will save you hassles sooner or later.