Hi
I haven't initialised a variable, and so the value I'm getting from it is some floating point number? I know this is because I haven't initialised it, but why does it contain a floating point number?
Thanks
Printable View
Hi
I haven't initialised a variable, and so the value I'm getting from it is some floating point number? I know this is because I haven't initialised it, but why does it contain a floating point number?
Thanks
It contains whatever was in memory before your program was run...maybe code...maybe other variables....maybe Bill Gate's phone number.....no way to know unless you get dialling!
Because the variable type you declared is floating point, the bits in that memory location are just interpreted as a floating point number. Remember, all variables are is just bits, plain and simple.
it could actually be some of your post in this thread... the bits are just read as a float instead of chars...
Yes, it's impossible for a float or double to contain anything besides a float or double -- whatever those 32 or 64 bits contain, it will be interpreted as a floating point. Technically I suppose you could get NaN as well, but the odds of that are very small.