include/fixedmath.h: Regarding the single precision float to/from fixed point conversions in fixedmath.h, I believe the floating point literals should be appended with the letter 'f' to avoid (expensive) conversions from single to double precision, and thereby also avoid (expensive if done in SW) double point arithmetic (which is what is happening upon inspection of my disassembly).

This commit is contained in:
rajan gill 2019-07-11 15:13:02 -06:00 committed by Gregory Nutt
parent 23df4a25d2
commit fdac44d193
1 changed files with 5 additions and 5 deletions

View File

@ -125,8 +125,8 @@
#define ub8toi(a) ((a) >> 8) /* Conversion to unsigned integer */
#define itob8(i) (((b8_t)(i)) << 8) /* Conversion from integer */
#define uitoub8(i) (((ub8_t)(i)) << 8) /* Conversion from unsigned integer */
#define b8tof(b) (((float)(b))/256.0) /* Conversion to float */
#define ftob8(f) (b8_t)(((f)*256.0)) /* Conversion from float */
#define b8tof(b) (((float)(b))/256.0f) /* Conversion to float */
#define ftob8(f) (b8_t)(((f)*256.0f)) /* Conversion from float */
#define b8trunc(a) ((a) & 0xff00) /* Truncate to integer b8 */
#define b8round(a) (((a)+0x0080) & 0xff00) /* Round to integer b8 */
#define b8frac(a) ((a) & 0x00ff) /* Take fractional part */
@ -157,9 +157,9 @@
#define ub16toi(a) ((a) >> 16) /* Conversion to unsgined integer */
#define itob16(i) (((b16_t)(i)) << 16) /* Conversion from integer */
#define uitoub16(i) (((ub16_t)(i)) << 16) /* Conversion from unsigned integer */
#define b16tof(b) (((float)(b))/65536.0) /* Conversion to float */
#define ftob16(f) (b16_t)(((f)*65536.0)) /* Conversion from float */
#define b16tod(b) (((double)(b))/65536.0)) /* Conversion to double */
#define b16tof(b) (((float)(b))/65536.0f) /* Conversion to float */
#define ftob16(f) (b16_t)(((f)*65536.0f)) /* Conversion from float */
#define b16tod(b) (((double)(b))/65536.0) /* Conversion to double */
#define dtob16(f) (b16_t)(((f)*65536.0)) /* Conversion from double */
#define b16trunc(a) ((a) & 0xffff0000) /* Truncate to integer */
#define b16round(a) (((a)+0x00008000) & 0xffff0000)