This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

numerical error handling with arm libraries

It appears that the only math related system errors handled by errno in the arm C libraries are:
EDOM,
ERANGE,
EILSEQ,

The default behavior for divide by zero is stated as "not trapped, returns a value of zero", which is probably never desired.

There are a number of methods proposed to actually handle it, but few or no examples. Which of the various methods is recommended? Any test code to demonstrate them?

Parents
  • > The default behavior for divide by zero is stated as
    > "not trapped, returns a value of zero", which is
    > probably never desired.

    You mean like in atan2()? Seems like one of the more popular trigonometric functions in embedded software to me.

    Seriously, though, catching a divide by zero before actually applying the division operation is easy enough. This is probably much more efficient than checking the result via errno. For floating point, there is the ieee_status (or similar) to check.

    The exact behaviour of ARM's division routines (and how to change it) is described here:
    infocenter.arm.com/.../index.html

    Hope this helps
    Marcus

Reply
  • > The default behavior for divide by zero is stated as
    > "not trapped, returns a value of zero", which is
    > probably never desired.

    You mean like in atan2()? Seems like one of the more popular trigonometric functions in embedded software to me.

    Seriously, though, catching a divide by zero before actually applying the division operation is easy enough. This is probably much more efficient than checking the result via errno. For floating point, there is the ieee_status (or similar) to check.

    The exact behaviour of ARM's division routines (and how to change it) is described here:
    infocenter.arm.com/.../index.html

    Hope this helps
    Marcus

Children