Floating Point Comparison Problems

We all learned (or should have learned) that comparing floating point numbers for equality is a risky proposition. The code:  if (a == b) { ... }could easily evaluate as not equal rather than equal if a and b differ due to round-off error. There are ways to deal with that involving making sure...

Controller Area Network (CAN) Protocol Vulnerabilities

Controller Area Network (CAN)is a very popular embedded network protocol. It's widely used in automotive applications, and the low cost that results in makes it popular in a wide variety of other applications.CAN is a very nice embedded protocol, and it's very appropriate for a wide variety of applications....

Avoid Floating Point Counters

Every once in a while I encounter code that uses a float to track time, keep count of events, or otherwise add small increments to a running sum. This can lead to some nasty bugs that don't show up during system test.Consider the following C code:#include #define SKIP 0x00FFFFF8int main(void){ ...