Last active
August 29, 2015 14:26
-
-
Save 0x5d/90433ac5e49bb304535c to your computer and use it in GitHub Desktop.
Machine epsilon calculation in some languages.
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
package main | |
import "fmt" | |
func main() { | |
x := 1.0 | |
for ; (1 + x) > 1; x = x / 2 { } | |
fmt.Printf("%v\n", x * 2) | |
} |
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
def machine_epsilon | |
x = 1.0 | |
while((1 + x) > 1) | |
x = x / 2 | |
end | |
x * 2 | |
end | |
puts machine_epsilon # The same as Float::EPSILON | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment