3 ms·
Yeah I'm not actually implementing anything but I'm curious about the common coding puzzle of "swap two numbers without a third variable" and what that's actual
by ummonk 4y ago
Yeah I'm not actually implementing anything but I'm curious about the common coding puzzle of "swap two numbers without a third variable" and what that's actually solvable in a non-platform specific way for signed integers given the limitations of what is actually guaranteed by the C standard.
- retrocryptid 4y agoA laudable goal, but keep in mind, neither gcc nor llvm are truly faithful to the c spec. (Though I haven't really studied C17, so maybe they've mended their ways.) I think I might say it like this: the exhibited behaviour of either gcc or llvm and the behaviour described in C11 are not proper subsets of each other. This whole exercise got me thinking if there's an architecture supported by gcc where unsigned {short, int, long, long long} and {short, int, long, long long} have different widths. (even though it's not mandated by the spec)