<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Wondering how to use fabs()</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/68807/wondering-how-to-use-fabs</link><description>Hello, 
 In my code I am reading from a sensor and want to check if the float value returned is out of range. In order to do so I would like to be able to calculate the absolute value of the float. Using abs() is not an option because it returns an integer</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 27 Nov 2020 09:05:48 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/68807/wondering-how-to-use-fabs" /><item><title>RE: Wondering how to use fabs()</title><link>https://devzone.nordicsemi.com/thread/282212?ContentTypeID=1</link><pubDate>Fri, 27 Nov 2020 09:05:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:97c4deb7-2ba7-44cc-aacf-bd76f74810b8</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Aleix&lt;/p&gt;
&lt;p&gt;Which standard library are you using?&lt;/p&gt;
&lt;p&gt;fabs() seems to work as expected for me when using the NEWLIB library:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_NEWLIB_LIBC=y&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;What if you assign the result of the fabs operation to another variable before you print it?&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Wondering how to use fabs()</title><link>https://devzone.nordicsemi.com/thread/281997?ContentTypeID=1</link><pubDate>Thu, 26 Nov 2020 10:06:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3e3e846c-87a3-4ff1-9441-081a01f1cd6a</guid><dc:creator>Krawlow</dc:creator><description>&lt;p&gt;Indeed (edited: well, it returns 14 bits that are understood as a float). Also, that does not affects the simple example I have posted, which to me has a strange outcome.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Wondering how to use fabs()</title><link>https://devzone.nordicsemi.com/thread/281993?ContentTypeID=1</link><pubDate>Thu, 26 Nov 2020 09:55:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:55829bd6-719d-463c-bf2f-c7980244b20e</guid><dc:creator>awneil</dc:creator><description>[quote userid="82199" url="~/f/nordic-q-a/68807/wondering-how-to-use-fabs"]reading from a sensor and want to check if the float value returned[/quote]
&lt;p&gt;Does the sensor really return a float value ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>