Skip to content

Instantly share code, notes, and snippets.

@0x5d
Last active August 29, 2015 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 0x5d/90433ac5e49bb304535c to your computer and use it in GitHub Desktop.
Save 0x5d/90433ac5e49bb304535c to your computer and use it in GitHub Desktop.
Machine epsilon calculation in some languages.
package main
import "fmt"
func main() {
x := 1.0
for ; (1 + x) > 1; x = x / 2 { }
fmt.Printf("%v\n", x * 2)
}
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