Safe Handling of Floating Point Math in C Code Embedded Applications

Paper #:
  • 2017-01-1619

Published:
  • 2017-03-28
DOI:
  • 10.4271/2017-01-1619
Citation:
Loucks, C., "Safe Handling of Floating Point Math in C Code Embedded Applications," SAE Technical Paper 2017-01-1619, 2017, doi:10.4271/2017-01-1619.
Author(s):
Affiliated:
Pages:
8
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™. 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.
Access
Now
SAE MOBILUS Subscriber? You may already have access.
Buy
Select
Price
List
Download
$27.00
Mail
$27.00
Members save up to 40% off list price.
Share
HTML for Linking to Page
Page URL

Related Items

Article
2016-09-06
Standard
2012-12-07
Training / Education
2010-03-15
Training / Education
2010-03-15
Technical Paper / Journal Article
2010-09-28