Skip to content
Snippets Groups Projects
Commit 6e35cb00 authored by Julien Lecoeur's avatar Julien Lecoeur Committed by Daniel Agar
Browse files

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
parent 02cee074
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment