PX4IO interface protocol: Fix rounding error

Issue: This conversion test failed with gcc 7.1.1 and clang 4.0.1:
```
ERROR [tests] conversion fail: input:  -0.8188, intermediate: -8187, result:  -0.8187
conv FAILED
Command 'tests' failed, returned -1
```

Fix: explicit rounding
This commit is contained in:
Julien Lecoeur
2017-08-07 15:11:49 +02:00
committed by Daniel Agar
parent 02cee07469
commit 6e35cb002f
+1 -1
View File
@@ -74,7 +74,7 @@
#define SIGNED_TO_REG(_signed) ((uint16_t)(_signed))
#define REG_TO_FLOAT(_reg) ((float)REG_TO_SIGNED(_reg) / 10000.0f)
#define FLOAT_TO_REG(_float) SIGNED_TO_REG((int16_t)((_float) * 10000.0f))
#define FLOAT_TO_REG(_float) SIGNED_TO_REG((int16_t)floorf((_float + 0.00005f) * 10000.0f))
#define PX4IO_PROTOCOL_VERSION 4