Do not use a float to store a pin number. Only use a float when you intend to store a number that is not an integer in it. Use an int for pin numbers - or better yet, a byte (which uses 1b of ram instead of 2 like an int, or 4 like a float); floating point numbers are also not truly accurate - they are inherently approximate. That said, this is not the cause of the problem.
I try to avoid floating point numbers like the plague, using any trick I can to avoid them. Beyond the inaccuracy I mentioned above, floating point math is all implemented in software (whereas for integers, only division is); each operator you have acting on a float (ie, addition, multiplication, etc) adds to sketch size by a surprising amount. They're also comparatively slow. It's not as hard as you might think at first glance to avoid them.
Reading (analog or digital) on a pin that is not connected to an external voltage will produce random readings - the pin is termed "floating" and will pick up random noise from the environment. You cannot differentiate between a floating pin and a pin with an external voltage applied by reading it - you must ensure via hardware that the pin always has a defined voltage on it (eg, have whatever is generating this voltage always connected), or use some other method to tell it that you've connected something (ex, another pin set INPUT_PULLUP which is grounded when you connect the thing that produces the external voltage).