Created
January 10, 2025 09:35
-
-
Save cloudhan/6d95bc65b4f477e6bf96be50ab10abba to your computer and use it in GitHub Desktop.
Demonstration of IEEE 754 floating point non-associative
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment