float overflow in C code on the S12 processor

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

float overflow in C code on the S12 processor

1,729件の閲覧回数
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 返信

905件の閲覧回数
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 件の賞賛
返信