i7-thaumaturgy-7964.md - tgtimes - The Gopher Times Err bitreich.org 70 hgit clone git://bitreich.org/tgtimes git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/tgtimes URL:git://bitreich.org/tgtimes git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/tgtimes bitreich.org 70 1Log /scm/tgtimes/log.gph bitreich.org 70 1Files /scm/tgtimes/files.gph bitreich.org 70 1Refs /scm/tgtimes/refs.gph bitreich.org 70 1Tags /scm/tgtimes/tag bitreich.org 70 1README /scm/tgtimes/file/README.md.gph bitreich.org 70 i--- Err bitreich.org 70 i7-thaumaturgy-7964.md (585B) Err bitreich.org 70 i--- Err bitreich.org 70 i 1 # This's opus C Thaumaturgy Err bitreich.org 70 i 2 Err bitreich.org 70 i 3 // Returns the smaller integer of x and y but without a branch Err bitreich.org 70 i 4 // (if/else/ternary, goto etc..) Err bitreich.org 70 i 5 // Normally min is implemented something like this: Err bitreich.org 70 i 6 // return x < y ? x : y; Err bitreich.org 70 i 7 // But we have a branch there so let's do it witout. (The branch Err bitreich.org 70 i 8 // free min could be used to merge arrays for example.) Err bitreich.org 70 i 9 // If x < y, then -(x < y) => -1 => all 1's in two complement Err bitreich.org 70 i 10 // representation. Err bitreich.org 70 i 11 // So we have y ^ (x ^ y) => x Err bitreich.org 70 i 12 // If x >= y, then -(x < y) => 0 so y ^ 0 is y. Err bitreich.org 70 i 13 Err bitreich.org 70 i 14 static inline uint8_t min(const uint8_t x, const uint8_t y) { Err bitreich.org 70 i 15 return y ^ ((x ^ y) & -(x < y)); Err bitreich.org 70 i 16 } Err bitreich.org 70 .