Skip to content

Instantly share code, notes, and snippets.

@cloudhan
Created January 10, 2025 09:35
Show Gist options
  • Save cloudhan/6d95bc65b4f477e6bf96be50ab10abba to your computer and use it in GitHub Desktop.
Save cloudhan/6d95bc65b4f477e6bf96be50ab10abba to your computer and use it in GitHub Desktop.

Revisions

  1. cloudhan created this gist Jan 10, 2025.
    7 changes: 7 additions & 0 deletions fp_assoc.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    import numpy as np
    a = np.array(3/7, dtype=np.float32)
    b = np.array(713/999, dtype=np.float32)
    c = np.array(7/11, dtype=np.float32)
    print("{:30.26f}\n{:30.26f}".format((a + b) + c, a + (b + c)))
    # 1.77864873409271240234375000
    # 1.77864885330200195312500000