An intro to Zig's integer casting for C programmers
IME the strict conversion rules in Rust and Zig can be quite a bummer for somebody coming from C because they may add a surprising amount of friction in day-to-day coding. Yes, C code is often way too sloppy when it comes to picking the right type (signed vs unsigned vs float), and it conveniently hides the problems if the wrong choice was made.<p>But sometimes the same value needs to be used in integer and floating-point math, and there is no single correct type for this value.<p>There are also some tricky choices in bit twiddling operations. Is it really such a problem when bits are shifted out of a value when this is normal behaviour down on the assembly level?<p>I guess I&#x27;ll eventually learn to live with strict explicit conversion, and eventually I&#x27;ll get better at picking the right type from the start, but I think implicit versus explicit conversion is an area where there is no &quot;completely right&quot; solution, because with 100% explicit conversions even coding down on the assembly level is more convenient ;)