Floating point numbers are always a little tricky since in many cases they're very close approxima
tions to the actual number. It's the tradeoff to give you a much larger range than the number of bits involved would suggest. Your method looks just fine to me, fwiw.
Tests for zero, or even equality with any number, can be a little weird. Unless there's some fudging in the scripting language I learned (back when computers were really rooms full of young woman with pencil and paper

) that rather than testing for float == 0.0 (well, float .eq. 0.0) it's better to test for abs(float) <= very small number. In this case I'd suggest something like 1.0e-6 but vsn is really determine
d by the tolerance of what you're measuring
.
Correct me if I'm wrong, it happens. HTH
Kirk