5 ms·
> I don't know how gcc generates its approximate 2-adic reciprocals. Possibly it uses something based on the Euclidean GCD algorithm. I wasn't able to find the
by thechao 6y ago
> I don't know how gcc generates its approximate 2-adic reciprocals. Possibly it uses something based on the Euclidean GCD algorithm. I wasn't able to find the precise line of source in a reasonable time.
It's 0x1FFF...F / 7 = 0x249...249249249.
Just about the oddest thing I've seen; I guess, if I were the author, it'd be my "1 in 10000" day?
- xyzzy_plugh 6y agoMakes more sense in binary: 0xFFF..F 111111111111111111111111 0x7 000000000000000000000111 0x249..9 001001001001001001001001
- svat 6y agoI think you're trying to explain what's special about the number -1227133513 or how it comes about / how one could arrive at it. This is something the author understands very well; in fact that's what the whole post is about (well, it's about more advanced matters, using this as a "hook"), and many nice methods to arrive at that number are discussed in the post and comments. (And BTW your computation corresponds to 1227133513 or -1/7, not to -1227133513 or 1/7.) The sentence you quoted is merely asking which of the many discussed methods gcc is actually using, and this cannot be answered by mathematics; it needs to be answered by pointing to the relevant source code.