[openbeos] Re: POSIX headers

  • From: François Revol <revol@xxxxxxx>
  • To: openbeos@xxxxxxxxxxxxx
  • Date: Thu, 18 Sep 2003 01:42:15 +0200

Selon Adi Oanca <e2joseph@xxxxxxxxxx>:

> From: "Ingo Weinhold"
> >
> > On 2003-09-17 at 20:25:36 [+0200], Adi Oanca wrote:
> > > ...forgot about round(). But then again... we don't have such a
> function.
> > > :-)
> > >
> > > From: "Adi Oanca" <e2joseph@xxxxxxxxxx>
> > > > From: "Matthijs Hollemans"> > Why do we use our POSIX headers, if they
> are
> > > > not completely
> > > > > > functional?
> > > > > > for example I want to use 'lroundf()' function found in math.h.
> > > > >
> > > > > According to a quick Google search I just did, lroundf() was added
> to
> > > the
> > > > > C99 standard. I don't think our version of gcc supports that
> standard,
> > > or
> > > > > does it?
> > > > >
> > > > > Then again, R5 only supports a fraction of POSIX anyway.
> > > >
> > > >     OK, be it like so.
> > > >
> > > >     Please tell me: how can I have a float's rounded value in an
> int32...
> > > >         float    y = 3.14f;
> > > >         int32   z = (int32)round( y );
> > > >             ... without a compiler warning?
> >
> > I wonder, what is the warning you get? It looks like perfectly legal code
> to
> > me. Or are you referring to the `implicit declaration...' error?
> 
>     Nope. That's strange, I went to BeOS and run an example... without
> warnings. A while back, I remember to have seen such a warning. I think I
> saw something else, maybe from:
>         msg->AddInt32("xxx", (int32)round(f));
>     ?
> 
>     Oh well.. it does not matter any more... the code above work just fine,
> so I'll use it.
> 
> > I wonder, why round() isn't declared for x86 in the R5 <math.h> header.
> The
> > symbol is in libroot and it seems to work, too.
> 
>     :-) In our math.h it isn't declared at all!
>     We need that guys, or should we use:
>         v = floorf( value>=0.0f? value+0.5f : value-0.5f );
>     ? :-)
> 
> 

WARNING

I remember trying to use one of those undeclared-but-existing 
funcs once (for ffmpeg), but it appeared that the func was 
broken, and didn't give correct results.

lrintf() or something IIRC.

François.

Other related posts: