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.

__isinf, __isnan and __isnormal on C2000 CLA FPU



Hello,

after implementing algorithms on the CLA I would like to check if input values are correct.

However I couldnt find any implementations of the functions  __isinf, __isnan or __isnormal for the CLA.

Is there any way to accomplish this?

thank you very much!

  • Hi,

    The CLA treats NaN as +inf, and denorm numbers as 0. There is no standard C math library for the CLA so we dont support the functions isin, isnan, isnormal.

    You will have to compare the hex representation of the number against +- inf to test for infinity.I would do it as follows

    #define IEEE754_SIGN_M   (1UL << 31)
    #define IEEE754_EXP_M    (0xFFUL)
    #define IEEE754_EXP_S    (23U)
    #define IEEE754_MANT_M   (0x7FFFFFUL)
    
    typedef _float32_t_
    {
        float    f32;
        uint32_t ui32;
        int32_t  i32;
    }float32_t;
    
    float32_t a = <some floating point operation>
    
    // Check for infinity
    if(((a.ui32 >> IEEE754_EXP_S) & IEEE754_EXP_M) == 255UL)
    {
        // Exponent is 255, a is +- Inf
    }
    else if (((a.ui32 >> IEEE754_EXP_S) & IEEE754_EXP_M) == 0UL)
    {
    
        // Subnorm (denorm) or zero
        
    }
    else
    {
        // normal range
    }