Your use of isnormal
does not look like anything idiomatic. I am not sure what you expect exactly from using isnormal
this way (it's obviously going to be true for 5.0*10.3
, I would expect the compiler to optimize it so), but here are at least some obvious problems assuming you use it for other computations:
Zero is not normal, so you shouldn't use isnormal
as a sanity check for a result that can be zero.
isnormal
will not tell you if your computation came so close to zero that it lost precision (the subnormal range) and went back into the normal range later.
You might be better served by FPU exceptions: there is one for each possible event for which you might want to know if it happened since you initiated your computations, and the way to use them is sketched out in this existing answer.