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?
For example
INT8 Function::Convertnumber(F32 number) { INT8 return; return = number; }
How about you provide an example that actually compiles, to begin with? Or better yet, one that actually demonstrates the full problem, i.e. one which people could actually run and see the problem for themselves?
Oh, and showing the definitions of INT8 and F32 might have been nice, too.
the typedefs are standard
typedef signed char INT8;
typedef float F32;
the simple example is enough to illustrate the problem. The issue is float to signed char conversion of the compiler. I'm using optimization level 3 which I believe might be part of the issue but I can't change that opt. level. Will probably have to accept the compiler bug and do a rewrite.
"Will probably have to accept the compiler bug and do a rewrite."
If you're confident it's a compiler bug, you should contact Keil technical support about it. They do listen to such things (provided you give good evidence).
View all questions in Keil forum