-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Doing the following will cause unexpected results;
Fix16 test = 5.0;
int divider = 2;
test /= divider;
The expected result would be 5.0, however it will instead be -32768.0 or
similar. This is because in C++ fix16_t is treated as an int, so that the
interface assumes the value 2 to be a fixed point value and not an integer.
The following code will work:
Fix16 test = 5.0;
int16_t divider = 2;
test /= divider;
This will produce the value 2.5 as expected because the interface treats
int16_t as an integer.
The problem is that I can't see a way to have the fix16_t type interoperable
with Fix16 class without sacrificing support for readable int maths. I'm not
sure that it's sensible to leave it working this way either though.
Original issue reported on code.google.com by [email protected] on 2 Mar 2011 at 1:17