[Mesa-dev] [PATCH 4/6] mesa/main: add IROUNDD64() helper

Iago Toral itoral at igalia.com
Mon May 15 10:51:03 UTC 2017


On Fri, 2017-05-12 at 10:33 +0200, Nicolai Hähnle wrote:
> On 11.05.2017 13:10, Iago Toral Quiroga wrote:
> > ---
> >  src/mesa/main/imports.h | 7 +++++++
> >  1 file changed, 7 insertions(+)
> > 
> > diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h
> > index ef7c378..416c59b 100644
> > --- a/src/mesa/main/imports.h
> > +++ b/src/mesa/main/imports.h
> > @@ -165,6 +165,13 @@ static inline GLint64 IROUND64(float f)
> >     return (GLint64) ((f >= 0.0F) ? (f + 0.5F) : (f - 0.5F));
> >  }
> > 
> > +/**
> > + * Convert double to int64 by rounding to nearest integer.
> > + */
> > +static inline GLint64 IROUNDD64(double d)
> > +{
> > +   return (GLint64) ((d >= 0.0) ? (d + 0.5) : (d - 0.5));
> > +}
> 
> Out of curiosity, can't you use round()? But I see that this matches 
> other code, so it's fine.

I think it should work just the same, but decided to go along with the
existing code.

> Cheers,
> Nicolai
> 
> 
> > 
> >  /**
> >   * Convert positive float to int by rounding to nearest integer.
> > 
> 
> 


More information about the mesa-dev mailing list