Forums - Floating point calculations?

4 posts / 0 new
Last post
Floating point calculations?
andrew42
Join Date: 30 Dec 16
Posts: 6
Posted: Thu, 2017-08-24 11:49

Hi,

I would like to be able to use float or double data types in calculations but I get undefined reference errors such as:

undefined reference to `__mulsf3'

I'm confused because if you declare a double and perform a calulation it works fine, and you can observe the computed result while debugging.

Example that works:

double result = 0.0;

result = 1.2*1.3;

However, if you try to do the calculation using a variable the errors show up.

Example that won't compile:

double result = 0.0;

double x = 1.2;

double y = 1.3;

result = x*y;

If the first example is able to store the correct result then what am I missing here? Can someone please explain this to me?

Thanks!

EDIT: A release build will compile with the second example, but I haven't confirmed correct funcitionality. Why won't it compile as a debug build?

EDIT 2: The release build does not appear to execute that peice of code, looks like it has been thrown out without the compiler saying anything. What is going on with this SDK?

  • Up0
  • Down0
Dr. Nissim Zur
Profile picture
Join Date: 6 Jun 16
Location: Skype: nissim.test CSR1010 External design house
Posts: 235
Posted: Thu, 2017-08-24 14:29

CSR1010 does not support float or double data types in runtime. As constant it works, since the compiler in your XIDE did it.

you must work in full byte or words. 

One way of doing that is to multiply all by 10 or 100 and divide the end result.... if you must. 

For example 3.14 *5.2 will become (314*52)/1000= 16

 

  • Up0
  • Down0
andrew42
Join Date: 30 Dec 16
Posts: 6
Posted: Thu, 2017-08-24 14:45

Thanks for your quick response Dr. Zur.

I assume there is no way to add floating-point support?

  • Up0
  • Down0
Dr. Nissim Zur
Profile picture
Join Date: 6 Jun 16
Location: Skype: nissim.test CSR1010 External design house
Posts: 235
Posted: Thu, 2017-08-24 21:29

I presume that if you have a good C library you can.

 

  • Up0
  • Down0
or Register

Opinions expressed in the content posted here are the personal opinions of the original authors, and do not necessarily reflect those of Qualcomm Incorporated or its subsidiaries (“Qualcomm”). The content is provided for informational purposes only and is not meant to be an endorsement or representation by Qualcomm or any other party. This site may also provide links or references to non-Qualcomm sites and resources. Qualcomm makes no representations, warranties, or other commitments whatsoever about any non-Qualcomm sites or third-party resources that may be referenced, accessible from, or linked to this site.