Skip to content

Instantly share code, notes, and snippets.

@dyoo
Created July 9, 2012 18:37
Show Gist options
  • Save dyoo/3078092 to your computer and use it in GitHub Desktop.
Save dyoo/3078092 to your computer and use it in GitHub Desktop.
Epsilon
#lang racket/base
;; http://en.wikipedia.org/wiki/Machine_epsilon
;; approximates the machine epsilon
(require racket/flonum)
(define (compute-machine-epsilon)
(let loop ([n 1.0])
(define new-n (fl/ n 2.0))
(cond
[(fl= 1.0 (fl+ 1.0 (fl/ new-n 2.0)))
new-n]
[else
(loop new-n)])))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment