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
  • the simple example is enough to illustrate the problem.

    No, it's not, because like I said before: it will not even compile.

    So the only problem this could possibly illustrate is that your command of the C++ programming language is not up to your own expectations.

    The reason I asked for a more fleshed-out example was that there's simply no way this is the actual function the problem you described appears in. For two reasons:

    1) to exhibit any run-time problem at all, the actual problematic would have had to survive compilation. This one doesn't.

    2) to exhibit the particular problem you claimed, the result of that convesion would have to have some way of making it out of that function. In this one, it doesn't.

    So whatever a function with the actual problem in it looks like, it would have to be so different from the sketch you posted that the latter cannot possibly serve as an illustration of the former.

Reply
  • the simple example is enough to illustrate the problem.

    No, it's not, because like I said before: it will not even compile.

    So the only problem this could possibly illustrate is that your command of the C++ programming language is not up to your own expectations.

    The reason I asked for a more fleshed-out example was that there's simply no way this is the actual function the problem you described appears in. For two reasons:

    1) to exhibit any run-time problem at all, the actual problematic would have had to survive compilation. This one doesn't.

    2) to exhibit the particular problem you claimed, the result of that convesion would have to have some way of making it out of that function. In this one, it doesn't.

    So whatever a function with the actual problem in it looks like, it would have to be so different from the sketch you posted that the latter cannot possibly serve as an illustration of the former.

Children