This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Error #223: floating-point value does not fit in required floating-point type

I saw two topics related to this error:

and 

but none oh them seems to solve my problem or mention that the problem will be solved in a future version.

I'm trying to initialize a float array with one value that does not fit in the float type, e.g: float record_input_type_float_array[...] = { 6.0222125053465465432132165463231562311E-45,161.9800415039, ... }

and compilers returns the following error: error #223: floating-point value does not fit in required floating-point type

On many cases my values will not fit in the float type, but I was expecting to get a rounded value in the float type (like others compilers), instead of getting a compilation error.

I also tried to suppress this error #223 with the --diag_warning=225, but without success. Is there any workaround?

I'm using ccsv5 - c6000_7.4.2 (compiler)


Regards,

  • I cannot reproduce that error diagnostic.  Please submit a test case.  You probably need to preprocess the code.  We also need to see the build options exactly as the compiler sees them.

    Thanks and regards,

    -George

  • George,

    Thanks for the quick response.

    Attached is a simple project where I were able to reproduce the issue on my environment.

    Is there any way to avoid/skip this error without preprocessing the code? The same code runs on other two compilers, so I were expecting to use the same code on the Texas environment.

    Regards,

    float_project.7z

  • Thank you for the test case.  I can reproduce the same error diagnostic.

    The TI compiler does not accept floating point constants smaller than FLT_MIN from <float.h>, which is 1.175494351E-38F .

    Thanks and regards,

    -George

  • George,

    What do you suggest to solve the problem?

    Is there any way to workaround this limitation without preprocessing the code?

    Best regards,
  • Murilo Travaglia72 said:
    Is there any way to workaround this limitation without preprocessing the code?

    That's all I can think of.  Try something like this ...

    #if defined(__TI_COMPILER_VERSION__)  // test for TI compiler
    #define VALUE 0
    #else
    #define VALUE 6.0222125053465465432132165463231562311E-45
    #endif
    
    float record_input_type_float_array[2] = {
      VALUE,
      161.9800415039
    };

    Thanks and regards,

    -George

  • George,

    Thanks for the feedback. The value: 6.0222125053465465432132165463231562311E-45 is not the only one that will cause problem, I can have many other values less than FLOAT support for TI compilers, so this solution won't solve my problem.

    Isn't there any way to force the compiler to cast the value to float like the other compilers?

    On another topic, mentioned on my first post, an user commented that this problem only appears on new version on ccs, do you think this problem is not reproducible in another tool version?

    Regards,



  • Murilo Travaglia72 said:
    Isn't there any way to force the compiler to cast the value to float like the other compilers?

    Unfortunately, no.

    Murilo Travaglia72 said:
    an user commented that this problem only appears on new version on ccs, do you think this problem is not reproducible in another tool version?

    This problem is present in all versions of the compiler.

    Thanks and regards,

    -George