https://xcancel.com/NateSilver538/status/1853673781350260902

  • DaPorkchop_@lemmy.ml
    ·
    18 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]
      ·
      edit-2
      18 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