-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] pow() nuttx libmath return wrong value #13286
Comments
@nicolas71640 did you try: pow(500.0f, (float) i); ? @pkarashchenko any idea? |
Just did... and same result |
Will need some debugging. The idea would be to check if there is FPU and if it is enabled. Like to check soft float vs hard float case. |
I stepped into similar strange behavior a long time ago, but not with Nuttx and here are the steps to check that can explain the observation:
|
@nicolas71640 could you please update description and add some steps that use |
With -00, the behavior is consistent and the above code displays :
IMPORTANT THING that I haven't mention before (my bad), is that I compile c++. The c code works perfectly, the c++ fails. I have no clue why...
Here's my defconfig :
|
Here's the two assembly code in c++ and c. The c works, the c++ doesn't. C++
C
|
Updates : (correction). |
Updates : To reproduct :
Gives :
|
@nicolas71640 please try the linked PR. I hope it should help |
I do not see a difference in assembly here. However in assembly from example
You can see that two calls of |
@pkarashchenko Thank you for your help, but it doesn't help. Still have the log(496.0) = 16.0000.... |
Strange, as I had the repro rate as you described and it was fixed by this change. Maybe there is something else. I will take a closer look. Also your message that C works and C++ does not work is something I can't fully understand. Could you please triple check this? |
@nicolas71640 can you increase |
I'm having other change under test. Seems my previous fix is wrong |
@nicolas71640 please check it new change works for you. At least my experiments show positive dynamic in particular cases including your example |
@pkarashchenko Just checked your PR, it works indeed ! Thanks ! |
Description / Steps to reproduce the issue
Here's a small example 1:
And the results on xmc4800-relax with the lib math package with nuttx
I've tried to compile with the gcc libmath, and no problem.
If a make i goes from 0 to 2 (instead of 3), my problem disapears...
Another strange issue is that this example 2 works :
In the case of example 1, I see that the pow() of libm is called. In the example 2, this function is not called. I have no idea why.
Thank you for any help understanding this issue...
On which OS does this issue occur?
[Linux]
What is the version of your OS?
Ubuntu 22
NuttX Version
12.6.0
Issue Architecture
[arm]
Issue Area
[Other]
Verification
The text was updated successfully, but these errors were encountered: