3 ms·
Both solutions add 0.5, the difference is where in the process it happens.
by yxhuvud 5mo ago
Both solutions add 0.5, the difference is where in the process it happens.
- account42 5mo agoThey don't - trunc(result * 255 + 0.5) is just round(result * 255), i.e. error is on average 0 whereas trunc(result * 256) has an average bias of -0.5.