diff options
| author | David Lechner <david@pybricks.com> | 2019-06-16 13:46:19 -0500 |
|---|---|---|
| committer | David Lechner <david@pybricks.com> | 2019-06-16 15:19:01 -0500 |
| commit | 3b7f96f9822f8d5dd2c3120ae00d3e6d862843dd (patch) | |
| tree | 4807518a8100b63ce6cbff5c9379b2d91f572d21 | |
| parent | 47a5aa74ff33b224b3f9150b0fff8b4a01d177fc (diff) | |
Add explicit cast in fix16_from_dbl()
This fixes the error:
implicit conversion from 'float' to 'double' to match other operand
of binary expression
When the compiler options -fsingle-precision-constant -Wdouble-promotion
are set
| -rw-r--r-- | libfixmath/fix16.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/libfixmath/fix16.h b/libfixmath/fix16.h index 8c5e9da..644776b 100644 --- a/libfixmath/fix16.h +++ b/libfixmath/fix16.h @@ -70,7 +70,7 @@ static inline fix16_t fix16_from_dbl(double a) {
double temp = a * fix16_one;
#ifndef FIXMATH_NO_ROUNDING
- temp += (temp >= 0) ? 0.5f : -0.5f;
+ temp += (double)((temp >= 0) ? 0.5f : -0.5f);
#endif
return (fix16_t)temp;
}
|
