cancel
Showing results for 
Search instead for 
Did you mean: 

The problem with calculations on types float with Cosmic compiler

krzysztof239955_st
Associate II
Posted on October 02, 2009 at 09:13

The problem with calculations on types float with Cosmic compiler

4 REPLIES 4
krzysztof239955_st
Associate II
Posted on May 17, 2011 at 15:04

Hi,

Why variable wsp_kal not have after the calculations of the correct value 0.000038?

Example:

float masa_kal,dzal_kal1,dzal_kal2,dzal_kal,wsp_kal;

masa_kal = (float)(mas_kal[i+1]-mas_kal[i]); // correct 5

dzal_kal1 = (float)kal_ram.dz_kal[i+1]; // correct 329602

dzal_kal2 = (float)kal_ram.dz_kal[i]; // correct 198530

dzal_kal = (float)(dzal_kal1-dzal_kal2); // correct 131072

wsp_kal = (float)(masa_kal/dzal_kal); // incorrect 0

mozra27
Associate II
Posted on May 17, 2011 at 15:04

Hi,

What is the compiler used in your application and what is the optimization level?

Please check with the following declaration:

float masa_kal,dzal_kal1,dzal_kal2,dzal_kal,wsp_kal = 0.0;

Regards

mozra

krzysztof239955_st
Associate II
Posted on May 17, 2011 at 15:04

Hi,

I use STVD 4.1.2 and the compiler Cosmic CxSTM8 4.3.1 with optimizations: Minimize code size (+compact). Declaration: float masa_kal,dzal_kal1,dzal_kal2,dzal_kal,wsp_kal=0.0; - not bring the improvement.

Best regards

krzysztof239955_st
Associate II
Posted on May 17, 2011 at 15:04

Hi,

The setting Display Item from Decimal on Standard in debuger solved the problem.

Best regards

krzysztof.skoczek