Skip to content

CPP interface misleading #8

@GoogleCodeExporter

Description

@GoogleCodeExporter
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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions