Need help with square root function (sqrt) on MCF52211

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Need help with square root function (sqrt) on MCF52211

1,463 Views
jayteemo
Contributor I
I'm having problems getting the sqrt (or sqrtf) function to work properly.
My targer processor is MCF52211.  CodeWarrior version 5.7.0.

When I run using sqrt, the result is always 20.0 and and the exception handler is entered, resulting in the error: "Access Error: Error on operand write".

When I run using sqrtf, the result is a very large, incorrect number.

I've tried using different msl libraries. 
Is there a specific library I should be using or a setting somewhere that I am missing?

Thanks.
Labels (1)
0 Kudos
Reply
1 Reply

660 Views
admin
Specialist II
It would probably be easier to include the source code of the sqrt() function into your program and compile it along with other sources. I suggest you use Cephes Math Library:
http://www.netlib.org/cephes/
Each function in this library is contained in a single source file. You can simply drop it into your sources folder and compile it with your project. Some minor modifications might be necessary.

0 Kudos
Reply