mirror of
https://github.com/apache/nuttx-apps.git
synced 2026-08-13 16:35:30 +00:00
Add math library support for trunc functions. From Brennan Ashton.
This commit is contained in:
parent
1987004b72
commit
8e79323694
1 changed files with 0 additions and 33 deletions
|
|
@ -149,39 +149,6 @@ float nanf(FAR const char *tagp)
|
|||
return 0;
|
||||
}
|
||||
|
||||
float truncf(float x)
|
||||
{
|
||||
union
|
||||
{
|
||||
float f;
|
||||
uint32_t i;
|
||||
} u =
|
||||
{
|
||||
x};
|
||||
int e = (int)(u.i >> 23 & 0xff) - 0x7f + 9;
|
||||
uint32_t m;
|
||||
|
||||
if (e >= 23 + 9)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
if (e < 9)
|
||||
{
|
||||
e = 1;
|
||||
}
|
||||
|
||||
m = -1U >> e;
|
||||
if ((u.i & m) == 0)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
FORCE_EVAL(x + 0x1p120f);
|
||||
u.i &= ~m;
|
||||
return u.f;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* mp_import_stat
|
||||
****************************************************************************/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue