UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Visitor t.bakker
Visitor
7,760 Views
Registered: ‎07-12-2015

Cross-compile fmod gives 0 for output

When cross-compiling the fmod function for the Zynq/Zybo board the function will output 0, but when natively compiled on the board the fmod function works perfectly fine. I am running the latest Xilinx-linux kernel.

 

Example:

 

#include <stdio.h>
#include <math.h>

int main()
{
    printf("Hello World\n");
    printf("fmod: %lf", fmod(5.3, 2));

    return 0;
}

I have also noticed some other strange behaviour when printing floats and doubles with std::cout, when cross-compiled vs native. Strangely enough I was thinkg maybe the some other math functions would have similar issue but using the tan() functions works perfectly fine. 

 

Does anybody have any idea on the possible root cause for this behaviour.

 

 

0 Kudos
2 Replies
Teacher muzaffer
Teacher
7,649 Views
Registered: ‎03-31-2012

Re: Cross-compile fmod gives 0 for output

fmod returns a double. Try (float)fmod(5.3,2) and see what happens.
- Please mark the Answer as "Accept as solution" if information provided is helpful.
Give Kudos to a post which you think is helpful and reply oriented.
0 Kudos
Visitor t.bakker
Visitor
7,629 Views
Registered: ‎07-12-2015

Re: Cross-compile fmod gives 0 for output

Performing an explicit cast did not have an effect on the outcome, and I wonder how it should in this case. Fmod function still returns 0 when cross-compiled and returns 1.3 when compiled on the Zynq board.

0 Kudos