Created
January 28, 2015 09:53
-
-
Save ladc/37f5f0ff2430750f80fb to your computer and use it in GitHub Desktop.
This file contains 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
local v1 = 1-5e-9 | |
local v2 = 1-5e-9-1e-16 | |
local function sprintf(...) | |
io.write(string.format(...)) | |
end | |
print("13 hex digits define a double, so these numbers are almost identical:") | |
sprintf("%.13a\n",v1) | |
sprintf("%.13a\n",v2) | |
print("However their \"%.8g\" representation is still different:") | |
sprintf("%.8g\n",v1) | |
sprintf("%.8g\n",v2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment