cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
Visitor
Visitor
7,809 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
Highlighted
Teacher
Teacher
7,698 Views
Registered: ‎03-31-2012

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
Highlighted
Visitor
Visitor
7,678 Views
Registered: ‎07-12-2015

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