This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Compiler isn't converting float to INT8 properly

I'm using Microvision 4
C compiler Armcc.Exe v4.0.0.524
When this compiler converts a floating point number (single precision) to INT8 it doesn't handle negative values properly.
For example
INT8 Function::Convertnumber(F32 number)
{ INT8 return; return = number;
}

this only works for positive numbers. If a negative value is passed into the function 0 is returned only. Seems like a bug in the compiler. I can't find any errata concerning this but i'm wondering if anyone else has noticed this problem and how it was solved?

Parents
  • First off, I see why you (well some of you anyway) guys are getting your panties in a bunch. I quickly edited some IP code which I can not legally provide here and noticed I put return instead of a variable in the declaration, for that I apologize.

    INT8 function::convertnumber(F32 number)
    { INT8 rc;

    rc = number; return(rc);
    }

    The code is C++ and the compiler stated was correct. It compiles C++ code quite well, so for the suggestions there thanks, but not an issue whatsoever. The issue was not the compiler after all, thankfully, as that would have really been a doozy of a problem in more ways than you would like to know. It was actually a configuration issue which wasn't real easy to determine, associated with the typedef for the INT8 not being done properly as a few of you pointed out. Sorry to raise a problem that wasn't a problem. take care

Reply
  • First off, I see why you (well some of you anyway) guys are getting your panties in a bunch. I quickly edited some IP code which I can not legally provide here and noticed I put return instead of a variable in the declaration, for that I apologize.

    INT8 function::convertnumber(F32 number)
    { INT8 rc;

    rc = number; return(rc);
    }

    The code is C++ and the compiler stated was correct. It compiles C++ code quite well, so for the suggestions there thanks, but not an issue whatsoever. The issue was not the compiler after all, thankfully, as that would have really been a doozy of a problem in more ways than you would like to know. It was actually a configuration issue which wasn't real easy to determine, associated with the typedef for the INT8 not being done properly as a few of you pointed out. Sorry to raise a problem that wasn't a problem. take care

Children