• plinky [he/him]@hexbear.net
        link
        fedilink
        English
        arrow-up
        2
        ·
        edit-2
        11 days ago

        Gotta dump results in some accumulate tho, and if then logic might be eh (although with branch prediction it might be auto 2 threads actually soviet-hmm or similar utilization at least)

        • DaPorkchop_@lemmy.ml
          link
          fedilink
          English
          arrow-up
          2
          ·
          10 days ago

          A reasonable compiler could optimize this into a bitwise AND, load the pointer to the appropriate string constant into a register branchlessly using a lookup table or cmov instruction, and then execute a single call to printf.

          • plinky [he/him]@hexbear.net
            link
            fedilink
            English
            arrow-up
            1
            ·
            edit-2
            10 days ago

            I mean if I want to know the precise number, like 40012 or whatever. Obviously single call is fast, but printf of 40000 strings single strings is meh. I mean in my variant I don’t run comparison, even bitwise, just 80000 rand and sum, single ceil and print