DigiNews

Tech Watch by Johan Denoyer

← Back to articles

Making all divisions slower to fix a bug in 0.000000000000000000542% of cases

Quality: 8/10 Relevance: 9/10

Summary

The post explains that 32-bit signed division by -1 can not produce the expected result due to two's complement overflow, which in C is undefined. It describes Futhark's approach of using unsigned arithmetic for all integer types and guarding the -1 divisor with a branch, ensuring defined outcomes at the cost of a per-division branch. It also evaluates the performance impact on CPU and GPU backends and provides practical advice for developers concerned with correctness and portability.

🚀 Service construit par Johan Denoyer