cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
tyski
Observer
Observer
3,939 Views
Registered: ‎01-24-2010

atof and strtod fail using soft fp libraries

I'm trying to use the MicroBlaze under 11.4 to parse strings to floating point numbers. The MicroBlaze I have is NOT configured with an FPU, so the conversions are being done entirely using the software floating point libraries. As an example of how I'm seeing atof and strtod fail, the following code prints "1072168960.000000" to the console:

 

double f = atof("0.75");

printf("%f", f);


Is there some sort of esoteric GCC command line option that is needed? Or is the stdlib code provided for the MicroBlaze simply incapable of software floating point string conversions? In contrast, software floating point arithmetic and floating point conversion TO strings works just fine. Only conversions from strings fails.

Thanks for any insight.

Tags (3)
0 Kudos
3 Replies
tyski
Observer
Observer
3,931 Views
Registered: ‎01-24-2010

I was originally including math.h in the file that was performing the string conversion, but when I removd the math.h include, the conversion now works just fine. Doesn't make sense, but at least it works now.

0 Kudos
brianhill
Xilinx Employee
Xilinx Employee
3,908 Views
Registered: ‎04-23-2008

I'd check on your stack and heap sizes. Make sure that your stack is 'beyond generous' when using the math library.

 

-Brian 

0 Kudos
fadjar
Visitor
Visitor
642 Views
Registered: ‎05-26-2018

I have same problem with you with vivado 2018 using Digilent Cmod A7, but after I insert

 

#include <stdlib.h>

 

in my program, the problem is gone and the atof function works properly!

 

 

0 Kudos