I tried to use round() function in my PPC application, but I'm getting "POLINK: error: Unresolved external symbol 'round'.". The same for roundf() and rintf(). Using PellesC 5.00.8.
I thought they were standard functions, so they shouldn't require any andditional libraries. I have listed all WinCE libraries anyway, and found no round() function, so I guess they aren't available on WinCE. But why would so basic function be not available? I guess I could write myself a round() equivalent, but I would rather like to use a standard one if it was available.
In my Win32 setup, v 6.00.4 (32 bit), it is in various forms in math.h, where I would expect it... :-\
Ralf
Quote from: Bitbeisser on December 10, 2009, 06:00:25 AM
In my Win32 setup, v 6.00.4 (32 bit), it is in various forms in math.h, where I would expect it... :-\
Ralf
I made a text search in the WinCE libraries and I did not find any round-function. So I assume that Pelle has no round-function for WinCE.
EDIT: But if it helps you, you can use casting of a float variable to int:
float f = 5.5;
int i = (int) f;
A rough and ready round function can be implemented like so;
int myround(double number)
{
return (number >= 0) ? (int)(number + 0.5) : (int)(number - 0.5);
}
John
I have found in PellesC help the page about intrinsic functions, and there is an information that rint() (which is just round() returning integer) is not available for ARM, so I guess it's the same for round() too.
I have written this function for rounding:
int froundi(float val)
{
if (val - floor(val) < 0.5)
return floor(val);
else
return ceil(val);
}
but JohnF's version seems better.
Thanks.
Quote from: AlexN on December 10, 2009, 10:39:49 AM
Quote from: Bitbeisser on December 10, 2009, 06:00:25 AM
In my Win32 setup, v 6.00.4 (32 bit), it is in various forms in math.h, where I would expect it... :-\
Ralf
I made a text search in the WinCE libraries and I did not find any round-function. So I assume that Pelle has no round-function for WinCE.
:oops: Sorry, my bad, I missed that he was not using a Win(32) setup/target... :-(
Ralf
Quote from: JohnF on December 10, 2009, 11:26:52 AM
A rough and ready round function can be implemented like so;
int myround(double number)
{
return (number >= 0) ? (int)(number + 0.5) : (int)(number - 0.5);
}
John
Good but I would prefer this:
#define round(x) ((x >= 0) ? (int)(x + 0.5) : (int)(x - 0.5))
It works for float, double and long double and you don't have the framework of a function call.
Zink,
I think that because of memory constrains with the PPC various standard functions are missing that are normally included.
John