Justin Ruggles <[email protected]> writes:

>  /**
> + * Get the next random float, in the range -0.5 to 0.5, using an ALFG.
> + */
> +static inline float av_lfg_get_flt(AVLFG *lfg)
> +{
> +    return (av_lfg_get(lfg) / (float)UINT32_MAX) - 0.5f;
> +}

The float subtraction can be avoided by first (carefully) turning the
av_lfg_get() return value into a signed integer and dividing by
2*INT32_MAX.  The relative difference in magnitude between INT32_MAX and
INT32_MIN is too small to be representable in 32-bit float (it does make
a difference in double precision).

-- 
Måns Rullgård
[email protected]
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to