AnsweredAssumed Answered

Float calculating problems with 548x

Question asked by Leandro Santos on Sep 6, 2010
Latest reply on Nov 24, 2010 by Leandro Santos

Hi there!


I'm with a problem using LTIB 20080811, kernel 2.6.25 with compiler 4.2-125. I wrote a program that make simple calculations.


The source code follows below:


#include <stdio.h>

#include <math.h>


static float misc_calculations();


int main(int argc, const char * argv[])


  float reference = misc_calculations();

  printf("Reference: %f\n", reference);


  while (1)


    float value = misc_calculations();

    if (value != reference)

      printf("Value: %f\n", value);




static float misc_calculations()


  const float float_a = .2;

  const float float_b = .152;

  float result = 0.0;


  result = float_a – float_b;


  return result;



When I execute two instances, the behavior is very strange.



Value: 2.411886                                                                 
Value: 156705821244071112293643497228883460096.000000                           
Value: 15.301361                                                                
Value: -174085336471250674867240960.000000                                      
Value: 1.250146                                                                 
Value: 2.771876                                                                 
Value: -2.302972                                                                
Value: 2.567792                                                                 
Value: -0.519974                                                                
Value: -1.523481                                                                
Value: 0.132017                                                                 
Value: 0.572767                                                                 
Value: -0.011594                                                                
Value: 2.511886                                                                 
Value: -1.523481                                                                
Value: 7.476519                                                                 
Value: -174085336471250674867240960.000000                                      
Value: 557824153357922598912.000000                                             
Value: 156705821244071112293643497228883460096.000000                           
Value: 1.511886                                                                 
Value: -2.579387                                                                
Value: 0.998819


This problem occurs when I run two process. Only one process, it's executed OK, but when you execute a top program, the errors also appear.


In kernel, I checked the definition CONFIG_FPU. I created the definition, but the result is still the same. For me, the problem is concurrency between process and the kernel is not saving the context.


I used another options as -msoft-float, -mcfv4e and -mcpu=5485.


Anyone ever had this problem?



Leandro dos Santos