float overflow in C code on the S12 processor

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

float overflow in C code on the S12 processor

1,726 次查看
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.

标签 (1)
0 项奖励
回复
1 回复

902 次查看
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 项奖励
回复