float overflow in C code on the S12 processor

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

float overflow in C code on the S12 processor

1,728 Views
andoni
Contributor I

Hi there!

We have C code (running on the S12) to verify, which makes heavy use of 32 bit floating point arithmetic.

The problem is that after exploring the floating point library the Codewarriors development studio has, we do not find any way to detect float overflows. Any help appreciated. Thanks in advance.

Labels (1)
0 Kudos
Reply
1 Reply

904 Views
kef
Specialist I

If it was C99, then you could  use standard macros from math.h: fpclassify(), isfinite(), isnan() etc. Unfortunately these macros are not available in CW.

I think is_special() function defined in "\Program Files\Freescale\CodeWarrior for S12(X) V5.0\lib\hc12c\src\Math.c" is what you want. Function is static, so you can't call it directly from your code. But you may look at it to see how you can detect if your number is not a number (is_special_nan), positive infinity (is_special_inf ) or negative infinity (is_special_minf).

 

Also you may want to clear errno before math function calls and check if errno zero after function calls. Possible errno errors are defined in errno.h

0 Kudos
Reply