• World Logic Day - A Programmers Riddle

    From Mostowski Collapse@21:1/5 to All on Tue Jan 17 15:52:11 2023
    Which C code runs faster:

    Variant 1:

    if (!(A || B))
    foo;
    else
    bar;

    Variant 2:

    if (!A && !B)
    foo;
    else
    bar;

    https://en.wikipedia.org/wiki/World_Logic_Day

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Mostowski Collapse@21:1/5 to Mostowski Collapse on Wed Jan 25 06:02:30 2023
    With these continuation values like NaN,
    the ! operator elimination is not that easy.
    We do not have anymore:

    ! (X <= Y) :<=> (X > Y)

    Here is a counter example, so code generator
    would need to generate a different code,
    than simply placing (<)/2:

    ! (NaN =< 1.0) --> true
    NaN > 1.0 --> false

    Mostowski Collapse schrieb am Dienstag, 17. Januar 2023 um 15:52:12 UTC+1:
    Which C code runs faster:

    Variant 1:

    if (!(A || B))
    foo;
    else
    bar;

    Variant 2:

    if (!A && !B)
    foo;
    else
    bar;

    https://en.wikipedia.org/wiki/World_Logic_Day

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)