Safe Handling of Floating Point Math in C Code Embedded Applications

Paper #:
  • 2017-01-1619

Published:
  • 2017-03-28
Author(s):
Affiliated:
Abstract:
The introduction of floating point math in Embedded Application ECU’s has made the implementation of complex math functions less error prone but not error proof. This paper shall focus on raising awareness of the pitfalls that come from the use of the basic floating point arithmetic operations, that is, Divide, Multiply, Add and Subtract. Due to the known pitfalls inherent in these basic math operations, it is proposed that a standard library with common functions appropriate for Powertrain Embedded applications (but not limited to Powertrain) be identified. This paper shall explore what these common functions will look like for both standard C code as well as the equivalent versions in Matlab™ Simulink™ One lesson the author of this paper has learned in his career is that companies are slow to adopt common standardized approaches to the basic functionality discussed here (as well as other possible common functions not discussed here.) This shortcoming results not only in duplication of effort but lower overall quality since the use of common libraries helps ensure the cascading of best practice through to final production release. The particular pitfalls this paper shall discuss are Divide-By-Zero, Overflow, Underflow and Loss-Of-Precision for both single and double precision floating point variables. This paper shall reference the IEEE-754 Floating Point standard used by most Embedded C applications. This paper shall discuss the importance of recognizing these pitfalls as well as understanding the trade-offs in terms of processor resources. Finally, this paper will show examples of possible implementations of common, re-usable functions in both C code and Simulink™.
Access
Now
SAE MOBILUS Subscriber? You may already have access.
Buy
Attention: This item is not yet published. Pre-Order to be notified, via email, when it becomes available.
Select
Price
List
Download
$22.00
Mail
$22.00
Members save up to 36% off list price.
Share
HTML for Linking to Page
Page URL

Related Items

Article
2016-02-02
Standard
2000-02-17
Article
2016-02-02
Technical Paper / Journal Article
2004-11-16
Training / Education
2010-03-15