[Mesa-dev] [PATCH 4/6] mesa/main: add IROUNDD64() helper
Nicolai Hähnle
nhaehnle at gmail.com
Fri May 12 08:33:08 UTC 2017
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.
Cheers,
Nicolai
>
> /**
> * Convert positive float to int by rounding to nearest integer.
>
--
Lerne, wie die Welt wirklich ist,
Aber vergiss niemals, wie sie sein sollte.
More information about the mesa-dev
mailing list