Given that PI/2 can never be represented precisely in floating point, is it safe to assume that cos(a) can never return exact zero?
If this is the case, then the following pseudo-code will never enter the block (and it could be safely removed):
...
y = h/cos(a);
if (!isfinite(a))
{
// handle infinite y
}
Zero is one of several values that can be represented exactly. Many systems have a lookup table for common values of sin and cos, so it’s not inconceivable that exactly zero could be returned.
But you are safer using a delta compare, before performing the division: