Re: [Mesa-dev] [PATCH] gallivm: Use nextafterf(0.5, 0.0) as rounding constant

2018-11-28 Thread Roland Scheidegger
Am 28.11.18 um 07:37 schrieb Matt Turner: > The common truncf(x + 0.5) fails for the floating-point value just less > than 0.5 (nextafterf(0.5, 0.0)). nextafterf(0.5, 0.0) + 0.5, after > rounding is 1.0, thus truncf does not produce the desired value. > > The solution is to add nextafterf(0.5,

[Mesa-dev] [PATCH] gallivm: Use nextafterf(0.5, 0.0) as rounding constant

2018-11-27 Thread Matt Turner
The common truncf(x + 0.5) fails for the floating-point value just less than 0.5 (nextafterf(0.5, 0.0)). nextafterf(0.5, 0.0) + 0.5, after rounding is 1.0, thus truncf does not produce the desired value. The solution is to add nextafterf(0.5, 0.0) instead of 0.5 before truncating. This works for